📄 gibbdemo.m
字号:
% 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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -