How to resolve this error "Array indices must be positive integers or logical values."
2 次查看(过去 30 天)
显示 更早的评论
syms p Dp D2p q Dq D2q x
r=0.09;
s=0.1;
m=0.03;
f=0.075;
vmax=100;
xf=90;
mum=0.5;
c=0.5;
t1=xf*vmax;
t2=((f*vmax+xf*Dq(-mum+3*m+12*(s^2))+4.5*(s^2)*(xf^2)*D2q)/(r-(3*m+3*(s^2))));
m1=(Dp/p)*x*(3*m+3*(s^2)-mum)+(9/2)*(x^2)*(s^2)*D2p/p;
ode = p-((x/((c^3)*sqrt(2)))*(1+m1+mum-r-f)^2);
D2ynum = solve(ode==0,D2p);
D2ynum = D2ynum(2);
f1 = matlabFunction(D2ynum,"Vars",{x, [p Dp]});
ode1=q-((p*f/x-mum*x*Dq+(3*m+3*(s^2))*Dq*x+(9/2)*(s^2)*(2*x*Dq+(x^2)*D2q))/(r-(3*m+3*(s^2))));
D2ynum1 = solve(ode1==0,D2q);
D2ynum1 = D2ynum1(1);
f2 = matlabFunction(D2ynum1,"Vars",{x, [p Dp q Dq]});
odefcn = @(x,y)[y(2);f1(x, [y(1) , y(2)]);y(4);f2(x, [y(1), y(2), y(3) ,y(4)])];
bcfcn = @(ya,yb)[ya(1);yb(1)-t1;ya(3);yb(3)-t2];
xmesh = linspace(0.001,xf,10);
solinit = bvpinit(xmesh, [0.001 0.001 0.001 0.001]);
sol = bvp4c(odefcn,bcfcn,solinit);
0 个评论
回答(1 个)
Torsten
2023-7-4
You forgot a multiplikation sign:
t2=((f*vmax+xf*Dq*(-mum+3*m+12*(s^2))+4.5*(s^2)*(xf^2)*D2q)/(r-(3*m+3*(s^2))));
instead of
t2=((f*vmax+xf*Dq(-mum+3*m+12*(s^2))+4.5*(s^2)*(xf^2)*D2q)/(r-(3*m+3*(s^2))));
2 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Ordinary Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!