vtb3_5.m

来自「The Engineering Vibration Toolbox is a s」· M 代码 · 共 53 行

M
53
字号
function [ap,bp]=vtb3_5(a0,a,b,N,T)%VTB3_5  Plot Fourier Series Approximation of Function.%  VTB3_5(a0,a,b,N,T) Plot the Fourier series defined by:%  N is the number of terms. Other arguments as defined by Inman%  a and b should ideally be strings as shown in the example following%%  Example%%  vtb3_5(-1,0,'-3*(-1+(-1)^n)/n/pi',20,2)%  %Plot a 20 term Fourier series representation of a shifted square wave%  %High value should be 1, low value should be -2.%% Copyright Joseph C. Slater, Dec 2006if nargin>0    if ~ischar(a0)        a0=num2str(a0);    end    if ~ischar(a)        a=num2str(a);    end    if ~ischar(b)        b=num2str(b);    end    if ischar(T)        T=str2num(T);    end    if ischar(N)        N=str2num(N);    end    t=0:T/400:T*3;    F=0*t+eval(a0)/2;    for n=1:N        F=F+eval(a)*cos(n*2*pi*t/T)+eval(b)*sin(n*2*pi*t/T);    end       plot(t,F)    grid on  else    vtb3_5(-1,0,'-3*(-1+(-1)^n)/n/pi',20,2)end

⌨️ 快捷键说明

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