example6_0.m

来自「经典《信号与系统》教程的matlab例程,对深入理解信号与系统相关概念有很大帮助」· M 代码 · 共 37 行

M
37
字号
% ======================================================================
% Example6_0
%========================================================================
clear,close all
t1=2;
p=0.001;
t=-t1:p:t1; 
T=1;
x1=1+0.5*cos(2*pi*t+1.2)+cos(4*pi*t+4.1)+2*cos(6*pi*t-7.02)/3;
x2=x1.*(u(t+T/2)-u(t-T/2)); 
N=3;
L=2*N+1;
k=-N:N;
for r=1:L;
    an(r)=(1/T)*x2*exp(-j*((-(L-1)/2+r-1)*2*pi/T)*t')*p;
    phi(r)=atan(imag(an(r))/real(an(r)));
end

subplot(211)
plot(t,x1)
axis([-t1,t1,-2,4])
title('The original signal x(t)')
xlabel('Time t'),grid on,

subplot(223)
k=-N:N;
stem(k,abs(an),'r.')
title('The amplitude ak of x(t)')
axis([-N,N,0,1.2])
grid on,xlabel('Frequency index k')
subplot(224)
k=-N:N;
stem(k,phi,'r.')
title('The phase of x(t)')
axis([-N,N,-pi,pi])
xlabel('Frequency index k')
grid on,

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?