FFT and plot amplitude spectrum
    5 views (last 30 days)
  
       Show older comments
    
    Samaneh Arzpeima
 on 6 Dec 2018
  
    
    
    
    
    Commented: Shubham Gupta
      
 on 10 Dec 2018
            hello everybody
I got stuck on this problem and really need your help
I must plot the amplitude spectrum of a data set. my data set is the attached “momentrate.mat”. The first column is ‘time(s)’ and the second one is ‘momentrate(Nm/s)’.these 2 columns give a plot like the left figure in attached pdf file.by
plot(momentrate(:,1),momentrate(:,2))
now I need to take the amplitude spectrum of the above plot, and it should be something like the right figure in attached pdf file.
I tried the following codes
y=momentrate(:,2);
t=momentrate(:,1);
dt=diff(t)
sample_frequency= numel(t)/(t(end)-t(1))
nfft=2^nextpow2(length(y));
Y=fft(y,nfft);
Y=Y(1:nfft/2);
m=abs(Y);
f=(0:nfft/2-1)*sample_frequency/nfft;
plot(f,m);
but this won't give me anything like what I suppose to have.
Can you please tell me what is wrong?
I would appreciate if you could explain to me with simple codes.
0 Comments
Accepted Answer
  Shubham Gupta
      
 on 7 Dec 2018
        You might wanna use "logarithmic plot" instead of simple plot. So last line would be
 loglog(f,m);
More Answers (0)
See Also
Categories
				Find more on Spectral Measurements in Help Center and File Exchange
			
	Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!