?? example3_4.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 + -