필터 지우기
필터 지우기

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
Torsten
Torsten 2018년 2월 7일
편집: Torsten 2018년 2월 7일
Yes.
See if you can really evaluate the structure:
t = 0.5;
result = ppval(spxdot,t)
Best wishes
Torsten.
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