Can i plot spectrum of a signal in Matlab

P
Praveen_sharma · Jan 29, 2024 · 1.9K views
Question
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 PhD Expert
Answered Aug 24, 2026
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)));

 

 

Have a different question? Ask here

Get a Free Consultation or a Sample Assignment Review!