⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 p8_17.m

📁 Advanced Engineering Mathematics using MATLAB by Harman, Dabney, Richert,书中全部源码
💻 M
字号:
% P8_17.M Fourier series of Square wave %% Plot the Fourier series of the function f(t) %   f(t)=1     0 < t < pi%   f(t)=-1   -pi < t <  0%clearT=2*pi		% Periodw0 = 2*pi/T	% Radian frequencyA=1		% AmplitudeK=(4*A)/pi;% Plot 5 terms of the seriest = -pi:.031:pi;	% Time points for plottingsizet=size(t);fn =(zeros(sizet));	% Fourier approximation at each typlt=zeros(sizet);		% For plot of f(t)% 5 termsfor n=1:5  fn= fn + K*(sin((2*n-1)*w0*t)/(2*n-1)); end					%for k=1:length(t)  if t(k) < 0    yplt(k)=-1;  else   yplt(k)=1;  end endclfsubplot(2,1,1),plot(t,fn,t,yplt,'--');xlabel('t')ylabel('f(t)')title('Fourier Series Approximation to Square Wave')legend(['N=',num2str(n)],'f(t)')% Add 5 more termsfor n=6:10  fn= fn + K*(sin((2*n-1)*w0*t)/(2*n-1)); end					subplot(2,1,2),plot(t,fn,t,yplt,'--');xlabel('t')ylabel('f(t)')legend(['N=',num2str(n)],'f(t)')%% Modify the script to allow an arbitrary number%  of components

⌨️ 快捷键说明

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