I have to solve 1d heat equation using ftcs with given boundry condition. u(0,t)=0, u(l,t)=0 u(x,0) = f(x) but i cannot understand how to use my this in for loop .
27 ビュー (過去 30 日間)
古いコメントを表示
f(x)=100; %given value of function
h = 0.1;% given value of step size
k = 0.01;%given value of time-step size
alpha = 0.25; % given value of thermal diffusivity in heat equation
lambda = alpha*k/h^2; %Difference method parameter
l = 1 ; % legth of thin rod
t = 1 ; % final time
n = l/h ; % intervals at x-axis
% W - Matrix for generating solutions
W(0,t)=W(l,t) = 0 ; %Dirichlet boundry conditions
% imposition of boundry conditions
W =zeroes (length(x), length(t));
W(:,1)=f(x); %intial condition
W(1,:)=0.0; %condition at x = 0
W(end,:)=0.0; %condition at x = L
%genrating the matrix
x = (0:h:l);
t=(0:k:t)';
W = zeroes(length(x), Length(t));
for i = 0:0.1
for j = 0:0.001
W(i,j) = W((1-2*lambda)*ones(n-1,1),0) + (lambda*ones(n-2,1),1) ;
end
end
回答 (1 件)
Sreedhar Arumugam
2021 年 9 月 7 日
It is my understanding that you want to implement a solution for 1-D heat solution using FTCS method.
Please refer to these submissions made on FileExchange -
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Heat and Mass Transfer についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!