Effacer les filtres
Effacer les filtres

Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

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

1 vue (au cours des 30 derniers jours)
Chinmay Sharma
Chinmay Sharma le 7 Fév 2018
Clôturé : MATLAB Answer Bot le 20 Août 2021
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 commentaires
Torsten
Torsten le 7 Fév 2018
Modifié(e) : Torsten le 7 Fév 2018
Yes.
See if you can really evaluate the structure:
t = 0.5;
result = ppval(spxdot,t)
Best wishes
Torsten.
Chinmay Sharma
Chinmay Sharma le 8 Fév 2018
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!

Réponses (0)

Cette question est clôturée.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by