ode solver error, too many argyments etc
12 次查看(过去 30 天)
显示 更早的评论
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 个评论
Walter Roberson
2018-10-16
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.
采纳的回答
Sophie Sophie
2018-10-16
5 个评论
Walter Roberson
2018-10-17
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 ?
更多回答(3 个)
Torsten
2018-10-16
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 个评论
madhan ravi
2018-10-16
编辑:madhan ravi
2018-10-16
[t,y] = ode15s(@rhs, tspan, ic, 'AbsTol', 1e-8, 'RelTol', 1e-7);
2 个评论
Sophie Sophie
2018-10-16
5 个评论
Steven Lord
2018-10-16
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.)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!