The easiest way is to create and plot a one-sided fft (link). The phase plot uses the angle function. To find the peaks and their locations, use the Signal Processing Toolbox findpeaks (link) function. Example ā
N = 1000;
t = linspace(0, 10*pi, N);
Fs = 1/(t(2)-t(1));
Fn = Fs/2;
s = sin(2*pi*5*t);
FTs = fft(s)/N;
Fv = linspace(0, 1, fix(N/2)+1)*Fn;
Iv = 1:length(Fv);
figure(1)
subplot(2,1,1)
plot(Fv, abs(FTs(Iv))*2)
grid
ylabel('Amplitude')
title('Amplitude Plot')
subplot(2,1,2)
plot(Fv, angle(FTs(Iv))*180/pi)
grid
xlabel('Frequency (Hz)')
ylabel('Phase (Ā°)')
title('Phase Plot')
Best Answer