How to define k in bcfun?

2 visualizaciones (últimos 30 días)
Richard Tsui
Richard Tsui el 2 de Mzo. de 2021
Respondida: Walter Roberson el 2 de Mzo. de 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

Respuestas (1)

Walter Roberson
Walter Roberson el 2 de Mzo. de 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.

Categorías

Más información sobre MATLAB Coder en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by