Frequency Analysis by Simulink
Afficher commentaires plus anciens
Hi,
Can someone explain me the steps to do spectral analysis of a signal that I have in a .mat file (sample rate used=1kHz).
I would like to display signal in frequency domain and extract some parameters as mean frequency.
I've tried to use spectrum scope block but it returns an error in some S-function.
Thanks
1 commentaire
Fangjun Jiang
le 7 Sep 2011
What is the error message?
Réponses (2)
Rick Rosson
le 7 Sep 2011
I would recommend trying it in MATLAB first. In the following code, I am assuming that the signal is stored in an M x 1 array called x, and that the sampling rate is a scalar called Fs:
filename = ...
x = load(filename);
Fs = 1000;
M = size(x,1);
dF = Fs/M;
f = -Fs/2:dF:Fs/2-dF;
X = fftshift(fft(x));
figure;
plot(f,abs(X));
HTH.
Rick
1 commentaire
cyberdyne
le 15 Sep 2011
Rick Rosson
le 7 Sep 2011
Alternaitively, you could use the function freqz. For more information:
>> doc freqz
HTH.
Rick
Catégories
En savoir plus sur Transforms dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!