/** Test program for Fourier transform of sine * functions. */ import uk.ac.ed.ph.signal.*; // Signal classes public class SineSignal { public static void main(String args[]) { // Make a RealSignal of 2048 RealSignal s = new RealSignal(2048); s.setSampleInterval(0.1); // Set sample interval // Make second RealSignal with same interval RealSignal t = s.clone(); // Fill s with sine wave of amp 10 and 0.5 Hz and // DC offset of 12 // t with sine wave of amp 2 and 0.8 Hz s.fillSine(10.0, 0.5, 0.0, 12.0); t.fillSine( 2.0, 0.8, 0.0, 0.0); s.add(t); // Add t to s s.toTextFile("s.data"); // Output s to text file // Make ComplexSignal with s as the real part ComplexSignal z = new ComplexSignal(s); z.weight(new Hanning()); // Apply Hanning window to stop // Ailiasing z.centreFourier(); // Take centred FFT // Get the modulus as a RealSignal RealSignal m = z.getRealSignal(); m.toTextFile("m.data"); // Output m to file } }