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

 채택된 답변

Joseph Cheng
Joseph Cheng 2014년 3월 28일

0 개 추천

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

추가 답변 (1개)

Subhash
Subhash 2022년 8월 18일

0 개 추천

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

카테고리

도움말 센터File Exchange에서 Operators and Elementary Operations에 대해 자세히 알아보기

질문:

H
H
2014년 3월 28일

답변:

2022년 8월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by