Can i plot spectrum of a signal in Matlab

Illustration
Praveen_sharma - 2024-01-29T13:52:28+00:00
Question: Can i plot spectrum of a signal in Matlab

I want to plot spectrum diagram which gives the frequency content of a signal x(t) for example if i draw spectrum of x(t) = 14 cos(200*pi*t -pi/3) by hand it will be two arrows at -100 and +100 with values 7e^(jpi/3) and 7e^(-jpi/3)     Can some software or matlab can do this for me

Expert Answer

Profile picture of John Michell John Michell answered . 2025-11-20

Fs = 1000;
t = 0:1/Fs:1-(1/Fs);
x = 14*cos(200*pi*t-pi/3);
xdft = (1/length(x))*fft(x);
freq = -500:(Fs/length(x)):500-(Fs/length(x));
plot(freq,abs(fftshift(xdft)));

 

 


Not satisfied with the answer ?? ASK NOW

Get a Free Consultation or a Sample Assignment Review!