[問題] ODE加入迴圈已回收

看板MATLAB作者 (硬度)時間15年前 (2010/05/31 15:39), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
這是我的程式 A=1; C=0.1; r0=C; xd0=0; x0=(r0)/A; v0=xd0/A; global w w0=0.1;dw=0.05; for i=1:5 w(i)=w0+(i-1)*dw dt=0.01; FT=1; %DUR=Duration, FT=final time tsp=0:dt:FT; NN=size(tsp); N=NN(2); %N= total number of nodes of time options=odeset('RelTol',0.000000001,'AbsTol',0.000000001); [t, y]=ode45('fnhfreq',tsp ,[x0 v0]',options); ym(i)=max(y(:,1)); plot(w,ym(i)); end function dy=fnhfreq(t,y) global w ro=1; A=1; mu=1; P=4; C=0.1; the=(C/A)^3; aa=y(1)*ro*(A^2); ab=(1+y(1)^3-the)^(1/3); F=aa*(1-y(1)/ab); ba=ro*(A^2); bb=2*(1+y(1)^3-the)^(4/3); G=ba*((y(1)^4)/bb-(2*y(1))/ab+3/2); fi=0; fo=P*sin(2*pi*w(i)*t); ca=fi*(the^(2/3))/(y(1)^2); cb=fo/(ab^2); cc=4*(ab^4); H=ca-cb+2*mu*(1/cc+1/ab-(the^(4/3))/(4*y(1)^4)-C/(A*y(1))); dy=[y(2);(-1)*(G*(y(2))^2+H)/F]; 現在我的問題是:因為副程式裡面的f0他裡面的w(i)是個迴圈,而我最後要畫出的是 每一個w和對應y函數裡面產生的的最大值,我現在的錯誤出現的是 ??? Error using ==> vertcat All rows in the bracketed expression must have the same number of columns. Error in ==> fnhfreq at 12 dy=[y(2);(-1)*(G*(y(2))^2+H)/F]; Error in ==> funfun\private\odearguments at 110 f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0. Error in ==> ode45 at 173 [neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, ... 現在令小弟不知所措,請求各位大大鼎力幫忙,感激不盡! -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.57.95.86
文章代碼(AID): #1C0sUXhU (MATLAB)