Finite Difference Method Boundary Value Problem
Mostrar comentarios más antiguos
Hi, I am lost in this Boundary Value Problem requiring to use Finite Difference Method:
I attached what I have done and the hint our professor provided, I also tried different methods from other matlab questions and youtube, but it always runs some error.
Below this is the code I hae so far, it works but it does not look correct, can anyone help please? I will really appreciate that!
%% Initialize parameters
clc,clear
T_B = 600; % boundary condition
T_E = 350; % boundary condition
T_Inf = 300;
M = 4;
L = 2.0;
% Discretization
num_nodes = 51;
num_segments = num_nodes-1;
h = L/num_segments;
% x = T_B:-h:T_E;
xj = 0:h:L;
Q=@(T)(-4*(300-T));
% Building up matrix
diagonal = [1/h; 2/h^2*ones(num_segments-1,1); 1/h];
A = diag( diagonal);
for i = 2:num_segments+1
A(i-1,i)=-1/h^2; A(i,i-1)=-1/h^2; %%%%%%%%%%%%%% signs
end
A(1,2)=0; A(num_segments+1,num_segments)=0;
b = [T_B/h; Q(xj(2:end-1))'; T_E/h]; %%%%%%%%%%%%%%% Q(xj(2_end-1))' not just Q
T=A\b;
plot(xj,T),grid
3 comentarios
Jan
el 10 de Nov. de 2021
Please mention, why you think, that "it does not look correct". This is an important information and therefore it is a good idea to share it with the readers.
Lingbai Ren
el 10 de Nov. de 2021
Jan
el 11 de Nov. de 2021
This does not clarify, wh yozu assume, that there is a problem. Remember, that the readers are not working in your field. So explain the problem like you would explain it to a rubber duck.
Respuestas (0)
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!