ode solver error, too many argyments etc

15 Ansichten (letzte 30 Tage)
Sophie Sophie
Sophie Sophie am 16 Okt. 2018
Kommentiert: Walter Roberson am 17 Okt. 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 Kommentar
Walter Roberson
Walter Roberson am 16 Okt. 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.
Caution: as of R2017a there is rhs() supplied by Mathworks in the Symbolic Toolbox

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Sophie Sophie
Sophie Sophie am 16 Okt. 2018
Can you kindly give me an example?
Do I do this everywhere that rhs is mentioned?
  5 Kommentare
Sophie Sophie
Sophie Sophie am 17 Okt. 2018
Casr_conc is refined in getParams.m
It’s a set value.
Pi_conc is also defined there.
Walter Roberson
Walter Roberson am 17 Okt. 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 ?

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (3)

Torsten
Torsten am 16 Okt. 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.

madhan ravi
madhan ravi am 16 Okt. 2018
Bearbeitet: madhan ravi am 16 Okt. 2018
[t,y] = ode15s(@rhs, tspan, ic, 'AbsTol', 1e-8, 'RelTol', 1e-7);
  2 Kommentare
Walter Roberson
Walter Roberson am 16 Okt. 2018
That will not work: it would invoke rhs with no arguments.
madhan ravi
madhan ravi am 16 Okt. 2018
edited code sir Walter

Melden Sie sich an, um zu kommentieren.


Sophie Sophie
Sophie Sophie am 16 Okt. 2018
This is my rhs.m code
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)
% setting up kinetic transitions as follows:
% ------------------------------------------
%
% [S1-y(1)] [S2-y(2)] [S3-y(3)] [S4-y(4)] [S5-y(5)]
% E.Ca <==> E'.Ca + Ca <==> E'.Ca2 (+ ATP) <==> E'.ATP.Ca2 <==> E'~P.ADP.Ca2
% /\ ^ ^ // \\
% || \\ \\ =========================>[S3a-y(16)] // \\
% || \\===============>[S2a-y(15)] E'.ATP.Ca [S6a-y(7)]// \\ [S6-y(6)]
% +Ca || [S1a-y(14)] E.ATP.Ca *E'-P.ADP.Ca2 E'~P.Ca2 (+ ADP)
% || E.ATP \\ //
% || (+ ADP) \\ //
% \/ \\ //
% (Pi +) E <==> *E-Pi <==> *E-P + Ca <==> *E-P.Ca <==> *E'-P.Ca + Ca <==> *E'-P.Ca2
% [S0-y(13)] [S11-y(12)] [S10-y(11)] [S9-y(10)] [S8-y(9)] [S7-y(8)]
%
% ---------------------------------------------------------------------------------------
p = getParams();
% formulate ODEs w/ Mass action kinetics
dS1dt = Ca* k_S0_S1 * y(13) + p.k_S2_S1 * y(2) - (p.k_S1_S0 + p.k_S1_S2) * y(1);
dS2dt = p.k_S1_S2 * y(1) + p.k_S3_S2 * y(3) + k_S3a_S2 * y(16) - (p.k_S2_S1 + Ca* k_S2_S3 + p.MgATP_conc * k_S2_S3a) * y(2);
dS3dt = Ca * k_S2_S3 * y(2) + p.k_S4_S3 * y(4) - (p.k_S3_S2 + p.MgATP_conc * p.k_S3_S4) * y(3);
dS4dt = p.MgATP_conc * p.k_S3_S4 * y(3) + p.k_S5_S4 * y(5) + Ca * k_S3a_S4 * y(16) - (p.k_S4_S3 + p.k_S4_S5 + k_S4_S3a) * y(4);
dS5dt = p.k_S4_S5 * y(4) + p.k_S6a_S5 * y(7) + p.k_S6_S5 * p.MgADP_conc * y(6) - (p.k_S5_S4 + k_S5_S6a + p.k_S5_S6) * y(5);
dS6dt = p.k_S5_S6 * y(5) + p.k_S7_S6 * y(8) - (p.k_S6_S5 * p.MgADP_conc + k_S6_S7) * y(6);
dS6adt = k_S5_S6a * y(5) + p.k_S7_S6a * p.MgADP_conc * y(8) - (p.k_S6a_S5 + p.k_S6a_S7) * y(7);
dS7dt = k_S6_S7 * y(6) + p.k_S6a_S7 * y(7) + Ca_sr_conc * p.k_S8_S7 * y(9) - (p.k_S7_S6 + p.k_S7_S6a * p.MgADP_conc + k_S7_S8) * y(8);
dS8dt = k_S7_S8 * y(8) + p.k_S9_S8 * y(10) - (Ca_sr_conc * p.k_S8_S7 + p.k_S8_S9) * y(9);
dS9dt = p.k_S8_S9 * y(9) + Ca_sr_conc * p.k_S10_S9 * y(11) - (p.k_S9_S8 + k_S9_S10) * y(10);
dS10dt = k_S9_S10 * y(10) + p.k_S11_S10 * y(12) - (p.k_S10_S11 + Ca_sr_conc * p.k_S10_S9) * y(11);
dS11dt = p.k_S10_S11 * y(11) + Pi * k_S0_S11 * y(13) - (p.k_S11_S0 + p.k_S11_S10) * y(12);
dS0dt = p.k_S11_S0 * y(12) + p.k_S1_S0 * y(1) + k_S1a_S0 * y(14) - (Ca * k_S0_S1 + Pi * k_S0_S11 + k_S0_S1a * p.MgATP_conc) * y(13);
dS1adt = p.MgATP_conc * k_S0_S1a * y(13) + Ca * k_S2a_S1a * y(15) - (k_S1a_S0 + Ca * k_S1a_S2a) * y(14);
dS2adt = Ca * k_S1a_S2a * y(14) + k_S3a_S2a * y(16) + k_S1_S2a * p.MgATP_conc * y(1) - (k_S2a_S1a + k_S2a_S1 + k_S2a_S3a) * y(15);
dS3adt = p.MgATP_conc * k_S2_S3a * y(2) * k_S2a_S3a * y(15) * k_S4_S3a * y(4) - (k_S3a_S2 + k_S3a_S4 + k_S3a_S2a) * y(16);
rates = [dS1dt;
dS2dt;
dS3dt;
dS4dt;
dS5dt;
dS6dt;
dS6adt;
dS7dt;
dS8dt;
dS9dt;
dS10dt;
dS11dt;
dS0dt;
dS1adt;
dS2adt;
dS3adt;
];
end
  5 Kommentare
Sophie Sophie
Sophie Sophie am 16 Okt. 2018
@Mahan, the files are attached in a zip file in the original comment.
Steven Lord
Steven Lord am 16 Okt. 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.)

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by