Finite Difference Method Boundary Value Problem

5 ビュー (過去 30 日間)
Lingbai Ren
Lingbai Ren 2021 年 11 月 10 日
コメント済み: Jan 2021 年 11 月 11 日
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 件のコメント
Lingbai Ren
Lingbai Ren 2021 年 11 月 10 日
Sorry, this is the plot I get
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 Center および File ExchangeLogical についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by