Loop never stops?
Mostrar comentarios más antiguos
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 comentarios
KSSV
el 16 de Jun. de 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
el 16 de Jun. de 2021
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Symbolic Math Toolbox en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!