ode solver error, too many argyments etc
조회 수: 18 (최근 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!