[英]How to create phase plot in Matlab?
I need to calculate spectrum of the signal and plot its magnitude and phase in matlab.我需要在 matlab 中计算信号的频谱和 plot 的幅度和相位。 I have figured out how to do the magnitude plot, but cant understand how to do a phase plot我已经想出了如何做 plot 的幅度,但不明白如何做一个阶段 plot
N = 1000; Ts = 0.05; Fs = 1/Ts;
t = [0:Ts:(N*Ts)-Ts];
xc = 4*exp(1i*5*pi*t) + 6*exp(1i*12*pi*t);
f=[-Fs/2:Fs/N:Fs/2-Fs/N];
Xc=fft(xc);
figure;
subplot(211)
plot(f,fftshift(abs(Xc))) ;title('Magnitude as a function of Hz');
xlabel('f in Hz');ylabel('|Xc|');grid on;
subplot(212)
w=2*pi*f;
plot(w,fftshift(abs(Xc))) ;title('Magnitude as a function of w');
xlabel('w');ylabel('|Xc|');grid on;
Any help would be appreciated任何帮助,将不胜感激
Replace abs
you use for a magnitude plot with angle
, like:将您用于幅度 plot 的abs
替换为angle
,例如:
plot(w,fftshift(angle(Xc))) ;title('Phase as a function of w');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.