Can't solve ODE with pchip and ppval
Hi, I'm getting a error I can't understand and I would love if someone could clarify for me why the following doesn't work: I have two ode's, one with and one without noise. The one with works, but the one without doesn't. The one without looks like this:
function [dFTdt] = SVP(t,x,p,SVP) alpha = p(1); beta = p(2); ki=p(3);
FT=x(1); dFTdt = zeros(1,1); dFTdt(1)=beta - ppval(SVP,t) * ki - FT * alpha; end
and the one with like this:
function [dFTdt] = SVPnoise(t,x,p,SVP) alpha = p(1); beta = p(2); ki=p(3);
FT=x(1); dFTdt = zeros(1,1); dFTdt(1)=beta - ppval(SVP,t) * ki - FT * alpha + normrnd(0,0.5); end
I can solve the one with noise in the following way:
[~,yx] = ode45(@(t,x) SVPnoise(t,x,BestLSQ12,SVP12),tData,FT(1,1))
where
BestLSQ12 = [327.1456 591.7595 471.9959]; SVP(:,1) = 0.5000 0.8000 0.3000 0.7500 0.5000 0.2500 0.2300 0.4000 0.2400 0.2000 0.7000 0.3500 0.3500 1.0100]; tData = 1.0000 1.3300 1.6600 2.0000 2.3300 2.6600 3.0000 3.3300 3.6600 4.0000 4.3300 4.6600 5.0000 5.3300]; SVP12 = pchip(tData,SVP(:,1)); FT(1,1) = 0.1000;
I solve the one without noise in the following way:
[~,yx] = ode45(@(t,x) SVP(t,x,BestLSQ12,SVP12),tData,FT(1,1))
and then I get the following error:
Function 'subsindex' is not defined for values of class 'struct'.
Error in @(t,x)SVP(t,x,BestLSQ22,SVP12)
Error in odearguments (line 87)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 115)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
I'm still a MATLAB novice, so I have no idea why this appears. I would love to know for future progress. If anyone care to write a short line about it---I would be very grateful. //Best regards
Accepted Answer
More Answers (0)
Categories
Find more on Ordinary Differential Equations 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!