I want to get FFT from my .mat data that have been saved in workspace. I have a timeseries data.>> t.mat (time) & data.mat (magnitude). I want to have a continuous plot for FFT .what must I do? can anyone help me? Thank you very much.

get fft from discrete data>> time and magnitude that have been saved as .mat file in workspace. How can I do that???

 採用された回答

Rick Rosson
Rick Rosson 2014 年 7 月 27 日
doc load
doc fft
doc fftshift
doc abs
doc plot

14 件のコメント

vahid torabi
vahid torabi 2014 年 7 月 27 日
編集済み: vahid torabi 2014 年 7 月 27 日
Thank you for answering,could you please expand your answer in more details sir?
Rick Rosson
Rick Rosson 2014 年 7 月 27 日
What have you tried so far?
vahid torabi
vahid torabi 2014 年 7 月 27 日
I added a JPG file that might help you.Thank you.
Image Analyst
Image Analyst 2014 年 7 月 27 日
編集済み: Image Analyst 2014 年 7 月 27 日
Rick knows what an FT is - he doesn't need an image like that to explain it. He was wondering if you attempted anything like
mySpectrum = fft(mysignal);
plot(real(mySpectrum), 'b-');
or anything like that. (Sounds like you have not attempted anything yet.) Have you tried to adapt the demo/example code in the help for fft() to your signal yet???
vahid torabi
vahid torabi 2014 年 7 月 27 日
I didn't want to make Rick sad,I just wanted to clarify what I'm gonna do.Sorry anyway. I've tried very codes to reach that FFT plot but I didn't. So now I'm very eager to know what is yours.Thank you very much.
Image Analyst
Image Analyst 2014 年 7 月 27 日
I gave you code, as did the help documentation. Did you see his comment "What have you tried so far?" We can't see it unless you copy it from your MATLAB script and paste it here, or else attach your m-file with the paper clip icon. Also supply data in addition to the code so we have something to run it on.
Rick Rosson
Rick Rosson 2014 年 7 月 27 日
Image Analyst is right. Please post your MATLAB code here so we can see what you have tried and then we can possibly help you.
vahid torabi
vahid torabi 2014 年 7 月 27 日
編集済み: vahid torabi 2014 年 7 月 27 日
these are my files. I've attached them. my code:
n = length(magnitude);
Ts = t(2)-t(1); % sample time
Fs = 1/Ts; % sampling frequency
NFFT = 2^nextpow2(n); % Next power of 2 from length of magnitude
Y = fft(magnitude,NFFT)/n;
f = Fs/2*linspace(0,1,NFFT/2+1);
% Plot single-sided amplitude spectrum.
plot(f,2*abs(Y(1:NFFT/2+1)))
title('Single-Sided Amplitude Spectrum of y(t)')
xlabel('Frequency (Hz)')
ylabel('|Y(f)|')
Rick Rosson
Rick Rosson 2014 年 7 月 27 日
Your code looks pretty good. Do you have any specific questions? Does your code work as expected? Are you getting any errors?
vahid torabi
vahid torabi 2014 年 7 月 28 日
I don't get any error.but the plot is not the thing I wanted to be! have you tried plotting with my files that I attached for you?
Rick Rosson
Rick Rosson 2014 年 7 月 28 日
編集済み: Rick Rosson 2014 年 7 月 28 日
Please add the following line of code at the very end of the script:
xlim([0 200e3]);
Also, try replacing the plot statement with:
plot(f,20*log10(abs(Y(1:NFFT/2+1))));
Label the y axis as:
ylabel('|Y(f)| (dB)')
Finally, in the line that computes the fft, instead of dividing by n, please divide by NFFT.
Does that help?
vahid torabi
vahid torabi 2014 年 7 月 28 日
It worked.My special thanks goes to you sir.I really appreciate your help.I admire you for your tips.Wish you luck.
vahid torabi
vahid torabi 2014 年 8 月 7 日
Hi back Mr.Rick. I attached a zip file that has the results. my plot starts at -80 but in article it starts at almost 0.why??? could you please help me sir??? thank you very much.
vahid torabi
vahid torabi 2014 年 8 月 7 日
this pdf has my results.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeFourier Analysis and Filtering についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by