Finite Difference Method Boundary Value Problem

4 次查看(过去 30 天)
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 个评论
Jan
Jan 2021-11-11
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.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Assembly 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by