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

 Akzeptierte Antwort

Joseph Cheng
Joseph Cheng am 28 Mär. 2014

0 Stimmen

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);

Weitere Antworten (1)

Subhash
Subhash am 18 Aug. 2022

0 Stimmen

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

Kategorien

Mehr zu Operators and Elementary Operations finden Sie in Hilfe-Center und File Exchange

Gefragt:

H
H
am 28 Mär. 2014

Beantwortet:

am 18 Aug. 2022

Community Treasure Hunt

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

Start Hunting!

Translated by