MATLAB: Can i plot spectrum of a signal in Matlab

spectrum

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

Best Answer

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)));