?? example3_5.m
字號:
% ======================================================================
% Example3_5
%========================================================================
clear,close all
t1=12;%input('Type in the time range:');
p=0.001;
t=-t1:p:t1;
T=2;%input('Type in the period T=:');
T1=T/4;
x1=u(t+T1)-u(t-T1);
x=0
for i=-t1:t1;
x=x+u(t-i*T+T1)-u(t-i*T-T1);
end
N=20;
L=2*N+1;
k=-N:N;
%an=2*T1*sin(k*2*pi*T1/T+eps)./(k*2*pi*T1/T+eps)/T;
%phi=atan(imag(an)./real(an));
for r=1:L;
an(r)=(1/T)*x1*exp(-j*((-(L-1)/2+r-1)*2*pi/T)*t')*p;
%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(211)
plot(t,x)
axis([-T,T,-0.2,1.2])
title('The original signal x(t)')
xlabel('Time t')
subplot(212)
k=-N:N;
stem(k,an,'r.')
text(4,max(an),'The amplitude ak of x(t)')
axis([-N,N,-0.5*max(abs(an)),1.2*max(abs(an))])
xlabel('Frequency index k')
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -