Info

此问题已关闭。 请重新打开它进行编辑或回答。

Matlab ode15s error: subscript indices must either be real positive integers or logicals.

1 次查看(过去 30 天)
Hello,
I have the following differential equation to be solved:
g1=0.988122979147950;
g2=0.644414268521746;
beta1=14.6523799554469;
beta2=-10.9849944881532;
beta3=411.648214174951;
g=227.598238564395;
n=1.56153644411635;
global spxdot;
shapeFunc=@(t,z)1-g1.*exp((-z.*abs(ppval(spxdot,t))/g2).^2).*ppval(spxdot,t).*(1-(beta1.*(sign(ppval(spxdot,t).*z)+beta2.*sign(ppval(spxdot,t)))+beta3.*sign(z)+ g).*(abs(z).^n));
trange=linspace(1,2401,2401)/1000;%converting to seconds
z0=0;%value of z at time t=0
[T,z1]=ode15s(shapeFunc,trange,z0);
But I am getting the following error:
Subscript indices must either be real positive integers or logicals.
Error in
differential>@(t,z)1-g1.*exp((-z.*abs(ppval(spxdot,t))/g2).^2).*ppval(spxdot,t).*(1-(beta1.*(sign(ppval(spxdot,t).*z)+beta2.*sign(ppval(spxdot,t)))+beta3.*sign(z)+g).*(abs(z).^n))
Error in odearguments (line 87)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode15s (line 150)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in differential (line 27)
[T,z1]=ode15s(shapeFunc,trange,z0);
Would somebody point out where I am doing the mistake? I double-checked the parens and operators but found nothing wrong.
Thanks,
  4 个评论
Chinmay Sharma
Chinmay Sharma 2018-2-8
I figured it out. I made a very silly mistake.
I had another experiment data struct named 'exp' in the workspace while running the code. Matlab assumed exp to be a struct rather than a function. Once that was removed, it worked fine.
Thanks for the help, and sorry for the trouble!

回答(0 个)

此问题已关闭。

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by