ode solver error, too many argyments etc
12 views (last 30 days)
Show older comments
Sophie Sophie
on 16 Oct 2018
Commented: Walter Roberson
on 17 Oct 2018
Hello community.
I am working on some code to optimize a protein pump. I keep getting the following errors
>> run script_runSS_CaDoseResponse.m
Error using
script_runSS_CaDoseResponse>@(t,y)rhs(t,y,k_S0_S1,k_S2_S3,k_S7_S8,k_S9_S10,k_S5_S6a,k_S6_S7,k_S0_S11,k_S0_S1a,k_S1a_S0,k_S1a_S2a,k_S2a_S1a,k_S1_S2a,k_S2a_S1,k_S2a_S3a,k_S3a_S2a,k_S2_S3a,k_S3a_S2,k_S3a_S4,k_S4_S3a,Ca,p.Pi_conc)
Too many input arguments.
Error in odearguments (line 90)
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 script_runSS_CaDoseResponse (line 78)
[t,y] = ode15s(@(t,y) rhs(t,y, k_S0_S1, k_S2_S3, k_S7_S8, k_S9_S10, k_S5_S6a, k_S6_S7, k_S0_S11, k_S0_S1a,
k_S1a_S0, k_S1a_S2a, k_S2a_S1a, k_S1_S2a, k_S2a_S1, k_S2a_S3a, k_S3a_S2a, k_S2_S3a, k_S3a_S2, k_S3a_S4, k_S4_S3a,
Ca, p.Pi_conc), tspan, ic, 'AbsTol', 1e-8, 'RelTol', 1e-7);
Error in run (line 91)
evalin('caller', strcat(script, ';'));
The code is attached.
I will be eternally greatful for any help!
1 Comment
Walter Roberson
on 16 Oct 2018
Your function named rhs does not expect that many input variables.
You have not posted your rhs.m so we do not know how many it does expect.
Accepted Answer
Sophie Sophie
on 16 Oct 2018
5 Comments
Walter Roberson
on 17 Oct 2018
You are calling getParams() as a function, so any local variable you set there is not made available to the calling function. Perhaps you need to refer to p.Ca_sr_conc ?
When you were constructing the code, what were you intending that last parameter to bring into the function ?
More Answers (3)
Torsten
on 16 Oct 2018
options = odeset('RelTol',1e-7,'AbsTol',1e-8);
[t,y] = ode15s(@(t,y) rhs(t,y, k_S0_S1, k_S2_S3, k_S7_S8, k_S9_S10, k_S5_S6a, k_S6_S7, k_S0_S11, k_S0_S1a, k_S1a_S0, k_S1a_S2a, k_S2a_S1a, k_S1_S2a, k_S2a_S1, k_S2a_S3a, k_S3a_S2a, k_S2_S3a, k_S3a_S2, k_S3a_S4, k_S4_S3a, Ca, p.Pi_conc), tspan, ic, options);
Best wishes
Torsten.
0 Comments
madhan ravi
on 16 Oct 2018
Edited: madhan ravi
on 16 Oct 2018
[t,y] = ode15s(@rhs, tspan, ic, 'AbsTol', 1e-8, 'RelTol', 1e-7);
2 Comments
Sophie Sophie
on 16 Oct 2018
5 Comments
Steven Lord
on 16 Oct 2018
In your function declaration line (broken across multiple lines to avoid scrolling in Answers):
function [rates] = rhs(t,y, k_S0_S1, k_S2_S3, k_S7_S8, ...
k_S9_S10, k_S5_S6a, k_S6_S7, k_S0_S11, k_S0_S1a, k_S1a_S0, ...
k_S1a_S2a, k_S2a_S1a, k_S1_S2a, k_S2a_S1, k_S2a_S3a, k_S3a_S2a, ...
k_S2_S3a, k_S3a_S2, k_S3a_S4, k_S4_S3a, Ca, p.Pi_conc)
the input arguments must be the name of a variable, the tilde operator, or varargin (as the last input.) Your last input argument is none of these; it is an expression referring to a field of a struct array or a property of an object. You need to change that to a variable name (or ~ if you don't need it to use it inside your rhs function but need your rhs function to accept it, to keep the syntax consistent with another tool's requirements for example.)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!