Loop never stops?
显示 更早的评论
Why does my loop never stops after I assign k1 & k2 as symbolic variables?
n=10;
T=sym(zeros(n,n));
T(1,:) = 410; % Top
T(end,:) = 420; % Bottom
T(:,1) = 400; % Left
T(:,end) = 400; % Right
T_old = T;
for k = 1:20 %time steps
for j = 2: (n-1)
for i = 2: (n-1)
%k1 = 0.02; k2=0.33;
syms k1 k2
T(i,j) = T_old(i,j)*(1-2*k1-2*k2)+k1*(T_old(i-1,j)+T_old(i+1,j))+k2*(T_old(i,j-1)+T_old(i,j+1));
end
end
T_old = T;
end
2 个评论
KSSV
2021-6-16
This line
syms k1 k2
need not to be loop, keep it at the begining. Are you sure you want k1, k2 to be symbolic?
Amanda Liu
2021-6-16
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Symbolic Math Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!