How to estimate three parameters in BVP5C
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I am trying to estimate three (unknown) parameters, c, N_0 and C_0 using BVP5C. The boundary problem I wish to solve consists of 4 first order ODEs, and 7 boundary conditions (4 for the variables, 3 required for the unknown parameters). Here is my code
xmesh = linspace(-50,-0.001,1000);
p = [0.3 0.01 0.5];
solinit = bvpinit(xmesh, @guess, p);
sol = bvp5c(@bvpfcn, @bcfcn, solinit);
Y=sol.y;
C=sol.parameters;
figure(5)
hold off
plot(sol.x, Y(2,:),sol.x, Y(4,:),'LineWidth',2)
function dydx = bvpfcn(~,y,c) % equation to solve
kappa = 2; sigma=0.01;
dydx = [(-c*y(1)-y(1)^2)/y(2)-kappa*(1-y(2))*y(4)+(1-y(4));
y(1);
sigma*y(2)*y(4);
y(3)];
end
%--------------------------------
function res = bcfcn(ya,yb,c,N_0,C_0) % boundary conditions
C_inf = 0.8; sigma = 0.01; M=50; kappa=2; gamma=-kappa*C_inf-1+C_inf;
res = [ ya(1)-gamma*N_0*exp(M*gamma/c)/c;
ya(2)-N_0*exp(M*gamma/c);
ya(3)-sigma*N_0*exp(M*gamma/c);
ya(4)-sigma*N_0*exp(M*gamma/c)-C_0;
yb(1)+c;
yb(2);
yb(4)-C_inf;
];
end
function g = guess(x)
g=[ -(x+1)*exp(x);
-x*exp(x);
0.5*exp(x);
0.5*(1+exp(x));
];
end
and I recieve the error message
Not enough input arguments.
Error in StefanCompetitionBVP>bcfcn (line 22)
res = [ ya(1)-gamma*N_0*exp(M*gamma/c)/c;
Error in bvparguments (line 106)
testBC = bc(ya,yb,bcExtras{:});
Error in bvp5c (line 137)
bvparguments(solver_name,ode,bc,solinit,options);
Error in StefanCompetitionBVP (line 5)
sol = bvp5c(@bvpfcn, @bcfcn, solinit);
I'm aware I'm messing up badly somewhere, I'm just not sure how to pass my unknown parameters to my local functions properly. Thanks.
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Numerical Integration and Differential Equations 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!