function a_FS()
%% »æ³öÔʼµÄÖÜÆÚÐźÅ
a = -5;b=5
t = a:0.01:b;
f = t*0;
t1 =t;t2= t;T =1.7;tao = 0.8;
f( find(t>=-tao/2&t<=tao/2) ) = 1;
figure;plot(t,f);axis([-1.5,1.5,0,1.2]);
for i=1:5
t1 = t1-T;f( find(t1>=-tao/2&t1<=tao/2) ) = 1;
t2 = t2+T;f( find(t2>=-tao/2&t2<=tao/2) ) = 1;
end
subplot(3,2,1)
plot(t,f);axis([a,b,0,1.2]);legend( 'raw_signal' );
%% ÏÂÃæÇóCn
N = 1000; w0 = 2*pi/T;
% n=0ʱ£¬c0µÄϵÊýÊǶàÉÙÄØ
C0 = tao /T; %CnÊÇËùÓÐÕýÏîµÄ¸µÀïҶϵÊý
for n=1:N
C(n) = (exp(-j*n*w0*tao/2)-exp(j*n*w0*tao/2)) / (-j*n*w0) /T; %CnÊÇËùÓÐÕýÏîµÄ¸µÀïҶϵÊý
c(n) = (exp(j*n*w0*tao/2)-exp(-j*n*w0*tao/2)) / (j*n*w0) /T; %cnÊÇËùÓиºÏîµÄ¸µÀïҶϵÊý
end
for i=2:6
f = C0*exp(0*t);
for n=1:i*4
f = f + C(n) * exp(j*n*w0*t) + c(n) * exp(-j*n*w0*t);
end
subplot(3,2,i);
plot(t,f);axis([a,b,0,1.2]);legend( ['N=',num2str(i*4)] );
end
figure;
f = C0*exp(0*t);
for n=1:32
f = f + C(n) * exp(j*n*w0*t) + c(n) * exp(-j*n*w0*t);
plot(t,f);axis([a,b,0,1.2]);legend( 'N=32' );hold on;pause;
end
end
2. function a_FT(t,f,T,tao,A)
%% »æ³öÔʼµÄÖÜÆÚÐźÅ
a = -5;b=5;
t = a:0.01:b;
f = t*0;
t1 =t;t2= t;T =1.7;tao =0.8;A=1;
f(find(t>=-tao/2&t<=tao/2) ) = A;
plot(t,f);axis([a,b,0,1.2]);legend( 'raw_signal' );
%% ÏÂÃæ¸µÀïÒ¶Õý±ä»»
F0 =1*tao;
n=1;
for w=1:0.005:40
Fw = -A*(exp(j*w*tao/2)-exp(-j*w*tao/2))/(-j*w); %CnÊÇËùÓÐÕýÏîµÄ¸µÀïҶϵÊý
F(n) = Fw;%ËùÓÐÕýÏò
Fw = -A*(exp(-j*w*tao/2)-exp(j*w*tao/2))/(j*w); %CnÊÇËùÓÐÕýÏîµÄ¸µÀïҶϵÊý
F_(n)=Fw;%ËùÓиºÊýÏî
n=n+1;
end
figure;
a = linspace(1,n-1,n-1);
plot(a/200,F);xlabel('x=w') ;hold on;plot(-a/200,F_);%FF_ÊǹØÓÚwµÄÁ¬Ðøº¯Êý