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

 Réponse acceptée

Joseph Cheng
Joseph Cheng le 28 Mar 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);

Plus de réponses (1)

Subhash
Subhash le 18 Août 2022

0 votes

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

Catégories

En savoir plus sur Operators and Elementary Operations dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by