⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 example3_4.m

📁 经典《信号与系统》教程的matlab例程,对深入理解信号与系统相关概念有很大帮助
💻 M
字号:
% ======================================================================
% Example3_4
%========================================================================
clear,close all
format long
t1=2;%input('Type in the time range:');
p=0.001;
t=-t1:p:t1;
T=1;%input('Type in the period T=:');
Nf=5;%input('Type in the number of the harmonic components');
x=1+sin(2*pi*t)+2*cos(2*pi*t)+cos(4*pi*t+pi/4);%input('Type in the expression of the signal x(t):');
x1=x.*(u(t+T/2)-u(t-T/2));
L=2*Nf+1;

for r=1:L;
    an(r)=(1/T)*x*exp(-j*((-(L-1)/2+r-1)*2*pi/T)*t')*p/(2*t1);
    phi(r)=atan(imag(an(r))/real(an(r)));
end
y=0;
for q=1:L;
      y=y+an(q)*exp(j*(-(L-1)/2+q-1)*2*pi*t/T);  
end;
subplot(221)
plot(t,x)
title('The original signal x(t)')
subplot(223)
plot(t,y)
title('The synthesis signal y(t)')
xlabel('Time t')
subplot(222)
k=-Nf:Nf;
stem(k,abs(an),'r.')
title('The amplitude |ak| of x(t)')
subplot(224)
stem(k,phi,'r.')
title('The phase phi(k) of x(t)')
xlabel('Index k')


⌨️ 快捷键说明

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