Boundary condition Problem solving using bvp4c
이전 댓글 표시
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.
답변 (2개)
Torsten
2015년 4월 15일
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.
카테고리
도움말 센터 및 File Exchange에서 Boundary Value Problems에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!