Loop never stops?
Show older comments
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 Comments
KSSV
on 16 Jun 2021
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
on 16 Jun 2021
Accepted Answer
More Answers (0)
Categories
Find more on Symbolic Math Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!