electronics forum

Rules | Recent posts | topic RSS | Search | Register  | Log in

help!!! precise spectrum analysis using Matlab


Post new topic  Reply to topic    EDAboard.com Forum Index -> Digital Signal Processing -> help!!! precise spectrum analysis using Matlab
Author Message
yujun61hugh



Joined: 05 Mar 2009
Posts: 1


Post05 Mar 2009 13:35   

how to calculate spectrum analysis in matlab


I need to get the precise spectrum component of the signal I generated in Matlab Simulink. The code i use now is shown as
Fs = 2e6; % Sampling frequency
T = 1/Fs; % Sample time
L = 2000000; % Length of signal
y = output(2001:(L+2001),2)';
NFFT = 2^nextpow2(L); % Next power of 2 from length of y
Y = fft(y,NFFT)/L;
f = Fs/2*linspace(0,1,NFFT/2);
plot(f,2*abs(Y(1:NFFT/2)))
title('Single-Sided Amplitude Spectrum of y(t)')
xlabel('Frequency (Hz)')
ylabel('|Y(f)|')

Basicly, I simulate the system for 1.001 sec. and take the last 1s data to do FFT.
However, when I test this code using an ideal sin wave with frequency 1K Hz and amplitude equal to 1. the FFT result shows that at the 1K Hz, the signal component is only 0.75. who could tell me the reason and how to improve the code. Thanks a lot.

Added after 7 minutes:

I upload the spectrum figure here.
help!!! precise spectrum analysis using Matlab
Back to top
Google
AdSense
Google Adsense




Post05 Mar 2009 13:35   

Ads




Back to top
rramya



Joined: 14 Dec 2008
Posts: 76
Helped: 19


Post07 Mar 2009 7:58   

linspace fft


Why are you lusing this line ???
y = output(2001:(L+2001),2)'; esp output???? (where is the sinuisoidal signal instead)

also, simulate the system for 1.001 sec.??? Y not simulate exactly for 1 sec.
because,the exact number of cycles of the "x"Hz sine wave that occur in the no. of
samples i/p signal should be an integer. for getting the proper spectrum.



another point : in the code you used

f = Fs/2*linspace(0,1,NFFT/2);

just use f = Fs/2*linspace(0,1,NFFT/2+1);
plot(f,2*abs(Y(1:NFFT/2)+1)) to plot the single sided spectrum.


if U have further doubt hen vsist the folowing site:

www.mathworks.com
in the search engine type fft, see documentation details.
also visit
www.mathworks.com/support/tech-notes/1700/1702.html
www.mathworks.com/support/tech-notes/1700/1703.html
www.mathworks.com/support/tech-notes/1700/1704.html


Happy learning
Back to top
Arabic versionBulgarian versionCatalan versionCzech versionDanish versionGerman versionGreek versionEnglish versionSpanish versionFinnish versionFrench versionHindi versionCroatian versionIndonesian versionItalian versionHebrew versionJapanese versionKorean versionLithuanian versionLatvian versionDutch versionNorwegian versionPolish versionPortuguese versionRomanian versionRussian versionSlovak versionSlovenian versionSerbian versionSwedish versionTagalog versionUkrainian versionVietnamese versionChinese version
Post new topic  Reply to topic    EDAboard.com Forum Index -> Digital Signal Processing -> help!!! precise spectrum analysis using Matlab
Page 1 of 1 All times are GMT + 1 Hour
Similar topics:
help needed in analysis of ECG Signal using MATLAB (39)
spectrum analysis code in MaTLaB(urgently required) (49)
spectrum analysis with the fft basics and Matlab 4 begineers (12)
spectrum analyzer using matlab and RS232 (1)
help me to analyse spectrum of discrete signal in matlab (4)
Traffic analysis using Matlab (4)
audio spectrum - need help with the Matlab code (3)
Radar Systems Analysis and Design Using MATLAB (5)
Upconverter & Receiver Spurious Analysis using MatLab (1)
help about pole zero analysis in MATLAB (3)


Abuse || Administrator || Moderators || Support us || sitemap
topic RSS