MATLAB Answers

How to define k in bcfun?

11 views (last 30 days)
Richard Tsui
Richard Tsui on 2 Mar 2021
Answered: Walter Roberson on 2 Mar 2021
function dYdy = odefun( x, Y, s, d )
T = Y(1);
dTdy = Y(2);
k = 0.001 * T + 1.2; % function of x, T, dTdx, etc.
f = -s/d; % function of x, T, dTdx, etc.
dYdy = [ dTdy / k; f ];
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% Function evaluating the boundary conditions: res = F( ya, yb, ... ) %
% %
% For this problem: y = [ y1 y2 ], y1 = T, y2 = k*dT/dy %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function res = bcfun( ya, yb, h, q0, Ta,)
res = [ ya(2) + q0/k ;
yb(2) + h*(yb(1) - Ta)/k ];
end

Answers (1)

Walter Roberson
Walter Roberson on 2 Mar 2021
In bcfun, for ya, you sould calculate k based on the x that would be used for the first boundary condition, and for yb you should calculate calculate k based on the x that would be used for the second boundary condition.

Community Treasure Hunt

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

Start Hunting!