ode solver error, too many argyments etc
15 ビュー (過去 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!