MATLAB BUILDER JA 2 Podręcznik Użytkownika Strona 239

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 292
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 238
Spectral Analysis Example
powerspect = [];
return;
end
if (interval <= 0)
error('Sampling interval must be greater then zero');
return;
end
fftData = fft(data);
freq = (0:length(fftData)-1)/(length(fftData)*interval);
powerSpect = abs(fftData)/(sqrt(length(fftData)));
plotfft.m
function PlotFFT(fftData, freq, powerSpect)
%PLOTFFT Computes and plots the FFT and power spectral density.
% [FFTDATA, FREQ, POWERSPECT] = PLOTFFT(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.
len = length(fftData);
if (len <= 0)
return;
end
plot(freq(1:floor(len/2)), powerSpect(1:floor(len/2)))
xlabel('Frequency (Hz)'), grid on
title('Power spectral density')
Spectral Analysis Example: Step-by-Step Procedure
1 Ifyouhavenotalreadydoneso,copythefilesforthisexampleasfollows:
a. Copy the following directory that ships with MATLAB to your work
directory:
matlabroot\toolbox\javabuilder\Examples\SpectraExample
b. At the MATLAB command prompt, cd to the new SpectraExample
subdirectory in your w ork directory.
5-9
Przeglądanie stron 238
1 2 ... 234 235 236 237 238 239 240 241 242 243 244 ... 291 292

Komentarze do niniejszej Instrukcji

Brak uwag