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

📄 ex8_2.m

📁 Advanced Engineering Mathematics using MATLAB by Harman, Dabney, Richert,书中全部源码
💻 M
字号:
% EX8_2.M Plot the Fourier series of the function f(t) %   f(t)=0  -pi < t < 0%   f(t)=t   0  < t < pi%% Plot f(t) for 5 and 20 terms in the seriescleart =[-pi:.031:pi];               % Time points for plottingsizet=size(t);fn = pi/4*(ones(sizet));        % Fourier approximation at each typlt=zeros(sizet);              %  for plot of f(t)% 5 termsfor n=1:5 fn=fn+ (1/pi)*(-2*cos((2*n-1)*t)/(2*n-1)^2)-((-1)^n*sin(n*t)/n); end					%for k=1:length(t)               % Create f(t)   if t(k) < 0    yplt(k)=0;  else   yplt(k)=t(k);  end endclf                             % Clear any figures subplot(2,1,1),plot(t,fn,t,yplt,'--');xlabel('t')ylabel('f(t)')title('Fourier series approximation to f(t) - Figure 8.2')legend(['N=',num2str(n)],'f(t)') % Annotate the graph% Add 15 more termsfor n=6:20 fn=fn+ (1/pi)*(-2*cos((2*n-1)*t)/(2*n-1)^2)-((-1)^n*sin(n*t)/n); endsubplot(2,1,2),plot(t,fn,t,yplt,'--');xlabel('t')ylabel('f(t)')legend(['N=',num2str(n)],'f(t)')%% Modify the program to compute an arbitrary number of terms %  in the series (i.e. input n). Plot the graph for many terms %  and notice the overshoot at the ends of the interval no matter%  how many terms are taken.%    (This is explained in the text as the Gibbs phenomenon.)

⌨️ 快捷键说明

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