I'm really new to matlab. How would I go about getting this to repeat from line 14 to 25 a certain number of times (iterate) for instance 131 times. I don't want it to print the result at each iteration just the resulting matrix after 131 iterations.
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 endendR(22,2)=-0.2; %implement implicit method
for i=2:22 for j=2:22 H1=0.25*(HOLD(i,j+1)+HOLD(i,j-1)+HOLD(i-1,j)+HOLD(i-1,j-1)) H2=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+100*100*0.002/4/300/0.1*HOLD(i,j)+100*100*R(i,j)/4/300) endendfor i=2:22 for j=2:22 HOLD(i,j)=HNEW(i,j) endend%No Flow Boundarys
for j=1:23 HOLD(1,:)=HOLD(3,:) HOLD(23,:)=HOLD(21,:)endfor i=1:23 HOLD(:,1)=HOLD(:,3) HOLD(:,23)=HOLD(:,21)end%Need to repeat from line 14 a specified number of times.
Best Answer