MATLAB BUILDER JA 2 User's Guide Page 238

  • Download
  • Add to my manuals
  • Print
  • Page
    / 292
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 237
5 Sample Applications (Java)
Spectral Analysis Example
The purpose of the example is to show you the following:
How to use MATLAB Builder for Java to create a component
(
spectralanalysis)containingaclassthathas a private method that is
automatically e ncapsulated.
Howtoaccessthecomponentin a Java application (
powerspect.java),
including use of the
MWArray class h ierarchy to represent data.
Note For complete reference inform atio n about the MWArray class
hierarchy, see the
com.mathworks.toolbox.javabuilder package.
How to build and run the application
The component
spectralanalysis analyzes a signal and graphs the result.
The class,
fourier, performs a Fast Fourier Transform (F FT) on an input data
array. A method of this class,
computefft, returns the results of that FFT
as two output arrays an array of frequency points and the power spectral
density. The second method,
plotfft, graphs the returned data. These two
methods,
computefft and plotfft, encapsulate MATLAB functions.
TheMATLABcodeforthesetwomethodsisin
computefft.m and plotfft.m, which can be found in
matlabroot\toolbox\javabuilder\Examples\SpectraExample\SpectraDemoComp.
computefft.m
function [fftData, freq, powerSpect] = ComputeFFT(data, interval)
% COMPUTEFFT Computes the FFT and power spectral density.
% [FFTDATA, FREQ, POWERSPECT] = COMPUTEFFT(DATA, INTERVAL)
% Computes the FFT and power spectral density of the input data.
% This file is used as an example for the .NET Builder
% product.
% Copyright 2001-2006 The MathWorks, Inc.
if (isempty(data))
fftdata = [];
freq = [];
5-8
Page view 237
1 2 ... 233 234 235 236 237 238 239 240 241 242 243 ... 291 292

Comments to this Manuals

No comments