Finite Difference Method Boundary Value Problem

14 views (last 30 days)
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
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;
% 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
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
Jan on 11 Nov 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.

Sign in to comment.

Answers (0)




Community Treasure Hunt

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

Start Hunting!

Translated by