gibbdemo.m

来自「biomedical stuffs...」· M 代码 · 共 34 行

M
34
字号
% gibbdemo.m
%	Demonstrates Gibb's phenomenon
%	User specifies number of Fourier series terms to use
%       upon request
%
%	This program is distributed as a supplement to the book
%	"Biomedical Signal Processing and Signal Modeling" by E. N. Bruce,
%	published by Wiley, 2000.  It is provided for educational use only.
%  While every effort has been made to insure its suitability to illustrate
%  principles described in the above book, no specific feature or capability 
%  is implied or guaranteed.
t=[0:256]'/256;
w0=2*pi; x=square(w0*t);
cont=1;
while cont==1
nin=input('How many harmonics do you want to use?  ');
xhat=zeros(size(x));
for k=1:2:nin
   xhat=xhat+sin(k*w0*t)*4/(k*pi);
end
figure
plot(t,x,t,xhat)
xlabel('Time')
title(['Signal Composed of ',num2str(nin), ' Harmonics']);

stp=input('Press 1 to repeat:  ');
if stp==1
cont=1;
else 
cont=0;
end

end

⌨️ 快捷键说明

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