现代通信系统(MATLAB版)(第二版) 图1.3 矩形脉冲的各种傅利叶级数的近似

%% %fourier tranform %draw the rect signal clear; x=[-2:0.01:2]; y=rect(x); plot(x,y); axis([-2,2,-0.2,1.2]); %draw the fourier serials hold on; %n=3; %z=fourierSerials(x,3); %plot(x,z); %text(0,1,'n=3'); for n=1:2:9; z=fourierSerials(x,n); plot(x,z); %text(n,1,num2str(n)); end n=0; z=fourierSerials(x,n); plot(x,z); hold off;

 

function [ y ] = rect( x) %UNTITLED Summary of this function goes here % Detailed explanation goes here num=length(x); i=0; while i<num i=i+1; if(x(i)>=-1 && x(i)<=1) y(i)=1; else y(i)=0; end end;

 

function [ y ] = fourierSerials( x,n) %UNTITLED2 Summary of this function goes here % Detailed explanation goes here m=1; while m<=length(x) sum=1/2; for i=1:n; if(n~=0) sum=sum+sinc(i/2)*cos(2*pi*x(m)*i/4); end; end; y(m)=sum; m=m+1; end; end

 

现代通信系统(MATLAB版)(第二版) 图1.3 矩形脉冲的各种傅利叶级数的近似_第1张图片

 

 

你可能感兴趣的:(现代通信系统(MATLAB版)(第二版) 图1.3 矩形脉冲的各种傅利叶级数的近似)