Too many input arguments?

2 ビュー (過去 30 日間)
Zack
Zack 2012 年 3 月 27 日
% ODE FILE
function bistabilitymin2 = bistabilitymin2(t,y,p)
% Parameter values given
for i=1:10
K(i)=p(i);
n(i)=1;
end
tauMD = p(11);
tauRP = p(12);
tauEE = p(13);
betaMD = 1;
betaRP = 1;
betaEE = 1;
S=0.01;
if t>50
S = 1;
end
a = 1/tauMD;
b = 1/tauRP;
c = 1/tauEE;
t1 = K(1)^n(1)/(K(1)^n(1)+S^n(1));
t3 = K(3)^n(3)/(K(3)^n(3)+y(1)^n(3));
t5 = K(5)^n(5)/(K(5)^n(5)+y(3)^n(5));
t6 = K(6)^n(6)/(K(6)^n(6)+y(2)^n(6));
t7 = y(1)^n(7)/(K(7)^n(7)+y(1)^n(7));
% System of ODEs where yp(1) = dMD/dt, yp(2) = dRP/dt, and yp(3) = dEE/dt
yp = zeros(3,1);
yp(1) = a*(t1-y(1));
yp(2) = b*(t3*t5-y(2))+0.2;
yp(3) = c*(t7*t6-y(3)); % dominant link
% yp(3) = c*(t7*t6-y(3)); % additive link
bistabilitymin2 = yp';
% Test file
clc;
clear all;
y0 = zeros(3,1);
p = zeros(13,1);
% Initial conditions for MD, RP, EE
% y0 = [0.01 11 0.01]' % quiescence state
y0 = [0 3.333 0]; % proliferation state
t0 = 0;
tfinal = 300;
% solve the system of ODEs that are specified in bistability.m
%for i=1:2
for j=1:10
p(j)=0.01+0.99*rand();
end
for j=11:13
p(j)=0.2+19.8*rand();
end
[t,y] = ode45('bistabilitymin2', [t0 tfinal], y0, [], p);
% MD{i}=y(:,1);
% RP{i}=y(:,2);
% EE{i}=y(:,3);
%end
For some reason, when I try to run my test file, I get an error stating that there are too many input arguments for my ODE file. I'm trying to pass the parameter values stored in p from my test file to my ODE file. Please let me know where I'm messing up, thanks!

回答 (1 件)

Jarrod Rivituso
Jarrod Rivituso 2012 年 3 月 27 日
When I did stuff like this, I always just created a wrapper function that does the parameter passing.
That would be replacing
[t,y] = ode45('bistabilitymin2', [t0 tfinal], y0, [], p);
with
bistabilityWrapper = @(t,y) bistabilitymin2(t,y,p);
[t,y] = ode45(bistabilityWrapper, [t0 tfinal], y0);
Essentially, the anonymous function passes the parameter p into the function, and then you use the anonymous function as an input to ode45.

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by