傅里叶分解周期函数时画不出分解后的图形,求解?
说一下我遇到的问题:刚开始程序还运行不了,我改了一下,总算能运行了,可总是画不出周期函数分解后的图,我的程序如下:function =CTFShchsymsyms t n k x T=4;tao=T/4;a=0;if nargin<4; Nf=6;endif nargin<5; Nn=32;endx=time_fun_x(t);A0=int(x,t,-a,T-a)/T;As=int(2*x*cos(2*pi*n*t/T)/T,t,-a,T-a);Bs=int(2*x*sin(2*pi*n*t/T)/T,t,-a,T-a);A_sym(1)=vpa(str2double(char(A0)),Nn);for k=1:Nf A_sym(k+1)=vpa(str2double(char(subs(As,n,k))),Nn); B_sym(k+1)=vpa(str2double(char(subs(Bs,n,k))),Nn);endif nargout==0 c=A_sym; disp(c) d=B_sym; disp(d) t=-3*T:0.01:3*T; f0=c(1); f1=c(2).*cos(2*pi*1*t/4)+d(2).*sin(2*pi*1*t/4); f2=c(3).*cos(2*pi*2*t/4)+d(3).*sin(2*pi*2*t/4); f3=f0+f1+f2; % 直流+基波+2次谐波 plot(t,f3); hold on y=time_fun_e(t); %调用连续时间函数-周期矩形脉冲 plot(t,y,&#39;r:&#39;); title(&#39;直流+基波&#39;); axis([-4,4,-0.5,1.5]); hold offend用的两个子函数是:function y=time_fun_e(t) a=0;T=4;h=1;tao=0.25*T;t=-3*T:0.01:3*T;e1=1/2+1/2.*sign(t-0.5+tao/2);e2=1/2+1/2.*sign(t-0.5-tao/2);y=h.*(e1-e2); 和function x=time_fun_x(t)h=1;x1=sym(&#39;Heaviside(t)&#39;)*h;x=x1-sym(&#39;Heaviside(t-1)&#39;)*h程序运行时系统提示:>> CTFShchsymWarning: Explicit integral could not be found. Warning: Explicit integral could not be found. Warning: Explicit integral could not be found. [ NaN, NaN, NaN, NaN, NaN, NaN, NaN][ 0, NaN, NaN, NaN, NaN, NaN, NaN]ans =[ NaN, NaN, NaN, NaN, NaN, NaN, NaN]我用debug检查,出错的地方应该在这:A0=int(x,t,-a,T-a)/T; As=int(2*x*cos(2*pi*n*t/T)/T,t,-a,T-a); Bs=int(2*x*sin(2*pi*n*t/T)/T,t,-a,T-a);完全不知道为什么,望高手指点~~~~~我用的是matlab2012a,64的window系统·
页:
[1]