Boundary condition Problem solving using bvp4c
9 views (last 30 days)
Show older comments
I was given this ODE problem:
g" + (1/2a) g' n = 0, where n = x/t^1/2, g(n) = T (x,t) BC1: g(0) = Ts = 100; BC2: g(infinity) = Ti = 10; Find g(n) and plot
I created 2 m.file
1)
function [ eqn ] = eqn1( n,g )
%Material Iron
rho = 7897;
Cp = 452;
k = 73;
alpha = k/(rho*Cp);
eqn =[g(2);(-n*g(2))/(2*alpha)];
end
2) function [ BCs ] = BC(g_0,g_inf)
Ts = 100;
Ti = 10;
BCs =[g_0(1)-Ts,g_inf(1)-Ti];
end
Then solution I tried to use bvp4c to solve for the equation
sol=bvpinit(linspace(0,1,25),[0 1]);
sol=bvp4c(@eqn1,@BC,sol)
I got this : Undefined function 'eqn1' for input arguments of type 'double'.
Error in bvparguments (line 106) testODE = ode(x1,y1,odeExtras{:});
Error in bvp4c (line 130) [n,npar,nregions,atol,rtol,Nmax,xyVectorized,printstats] = ...
Please Point out where did i do wrong and how can i fix it. THanks in advance.
0 Comments
Answers (2)
Torsten
on 15 Apr 2015
You arranged your code as
function main
solinit=bvpinit(linspace(0,1,25),[0 1]);
sol=bvp4c(@eqn1,@BC,solinit)
function [ eqn ] = eqn1( n,g )
%Material Iron
rho = 7897;
Cp = 452;
k = 73;
alpha = k/(rho*Cp);
eqn =[g(2);(-n*g(2))/(2*alpha)];
function [ BCs ] = BC(g_0,g_inf)
Ts = 100;
Ti = 10;
BCs =[g_0(1)-Ts ; g_inf(1)-Ti];
?
Best wishes
Torsten.
0 Comments
See Also
Categories
Find more on PDE Solvers in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!