How to resolve this error "Array indices must be positive integers or logical values."
2 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Torsten
on 4 Jul 2023
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 Comments
Torsten
on 4 Jul 2023
t2 is still a symbolic expression - you can't use it in the definition of "bcfcn".
See Also
Categories
Find more on Numbers and Precision in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!