How to get Magnitude Spectrum of a Cosine Wave

조회 수: 5 (최근 30일)
Upesh
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...

채택된 답변

Salaheddin Hosseinzadeh
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!
  댓글 수: 1
Upesh
Upesh 2014년 8월 29일
thanks for the help..really appreciated.

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Salaheddin Hosseinzadeh
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

Lizy
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

카테고리

Help CenterFile Exchange에서 Spectral Measurements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by