How to get Magnitude Spectrum of a Cosine Wave
12 ビュー (過去 30 日間)
古いコメントを表示
Upesh
2014 年 8 月 29 日
回答済み: Salaheddin Hosseinzadeh
2014 年 9 月 11 日
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!