How to get Magnitude Spectrum of a Cosine Wave
12 次查看(过去 30 天)
显示 更早的评论
im trying to get magnitude spectrum of a cosine wave x(t)=cos(2*pi*fo*t),0<t<T; where fo=2000hz and sampling frequency Fs=32kHz.Also,samples need be generated at the rate of Fs over a time interval T. (signal length T has to be chosen such that there are 1024 samples of the simulated analog signal).
im not getting the correct spike...
0 个评论
采纳的回答
Salaheddin Hosseinzadeh
2014-8-29
Hi Upsesh,
This can be solved by properly using fft (Fast Fourier Transform)
I wrote a fftplot function wich plots the magnitude and returns the coeffs, I'll attach it here, have a look at it and you'll learn how to use FFT. I'll also attach a PDF file regarding how to use FFT.
Hope this helps.
Good Luck!
更多回答(2 个)
Salaheddin Hosseinzadeh
2014-9-11
Hi Lizy,
Please do us a favor
1- edit your code so that we can read it. As it's really hard to follow, make it something like this
sample = 1000;
fs = 500;
2- Why don't you use, the files I attached in my previous answer? (the one above). If you don't like my code at least you can use MATLAB's imbedded fft function which take the Fourier transform of your signal?!
Please try the files provided, in the accepted answer or try fft and if you still had problem let us know.
doc fft
Good Luck
0 个评论
Lizy
2014-9-9
Hi, I need help to plot magnitude spectrum.. I've tried the following codes but it seems not working.. pls help ... thanks in advance ..
sample= 10000; % contains 10000 points -- sampling frequency f = 500; t = linspace(-f,f,sample+1); % frequency vector -500Hz<= f<500Hz t = t(1:end-1)
figure S2f = exp((-j*4*pi*f)./(2+j*2*pi*f)^2)+((1./200*pi)*(sin(inf)-sin(400*pi))); S2f_mag = abs(S2f); plot(S2f_mag) % plot magnitude spectrum title('Magnitude Spectrum S2(f)') hold on
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Fourier Analysis and Filtering 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!