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 .
22 次查看(过去 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!