Printing final result after iteration

Why is this displaying the result after each iteration rather than the final result only after the specified three iterations? How can I edit it to only print the matrix after the 3rd iteration? Thank you!!
clear;
HOLD=zeros(23,23);
HNEW=zeros(23,23);
R=zeros(23,23);
%Initial Value of matrix
for i=1:23
for j=1:23
HOLD(i,j)=10;
HNEW(i,j)=10;
end
end
R(22,2)=-0.2;
for RepeatNumber = 1 : 3
%implement implicit method
for i=2:22
for j=2:22
H2(i,j)=0.25*(HNEW(i,j+1)+HNEW(i,j-1)+HNEW(i-1,j)+HNEW(i-1,j-1));
HNEW(i,j)=(1/((100*100*0.002/4/300/0.1)+1))*(H2(i,j)+100*100*0.002/4/300/0.1*HOLD(i,j)+100*100*R(i,j)/4/300);
end
end
for i=2:22
for j=2:22
HOLD(i,j)=HNEW(i,j);
end
end
%No Flow Boundarys
for j=1:23
HOLD(1,:)=HOLD(3,:);
HOLD(23,:)=HOLD(21,:);
end
for i=1:23
HOLD(:,1)=HOLD(:,3);
HOLD(:,23)=HOLD(:,21);
end
%Need to repeat from line 14 a specified number of times.
end
for i=2:22
for j=2:22
HFINAL(i,j)=HOLD(i,j)
end
end

 Respuesta aceptada

Joseph Cheng
Joseph Cheng el 28 de Mzo. de 2014
put the ; at the end of your HFINAL(i,j)=HOLD(i,j);
then after the for RepeatNumber =1:3 loop is finished do
disp('Final Matrix:');
disp(HFINAL);

Más respuestas (1)

Subhash
Subhash el 18 de Ag. de 2022

0 votos

While solving the maximize problem program is running succesfulynow how to display final results

Categorías

Más información sobre Operators and Elementary Operations en Centro de ayuda y File Exchange.

Preguntada:

H
H
el 28 de Mzo. de 2014

Respondida:

el 18 de Ag. de 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by