User`s guide
5 Sample Applications (Java)
* Sampling interval = 0.01
*/
int[] dims = {1, nSamples};
data = MWNumericArray.newInstance(dims, MWClassID.DOUBLE,
MWComplexity.REAL);
for (int i = 1; i <= nSamples; i++)
{
double t = (i-1)*interval;
double x = Math.sin(2.0*Math.PI*15.0*t) +
Math.sin(2.0*Math.PI*40.0*t) +
Math.random();
data.set(i, x);
}
/* Create new fourier object */
theFourier = new fourier();
/* Compute power spectral density and plot result */
result = theFourier.plotfft(3, data,
new Double(interval));
}
catch (Exception e)
{
System.out.println("Exception:"+e.toString());
}
finally
{
/* Free native resources */
MWArray.disposeArray(data);
MWArray.disposeArray(result);
if (theFourier != null)
theFourier.dispose();
}
}
}
5-12