clear clcdx=0.5nx=uint32(5/dx+1)ny=uint32(5/dx+1)[X Y]=meshgrid(linspace(0,5,nx),linspace(0,5,ny))Tint=0T=Tint*ones(ny,nx)Tleft=100Tright=0Ttop=0Tbottom=0 T(:,1)=TleftT(:,end)=TrightT(1,:)=TtopT(end,:)= Tbottomk=3itr=200 for k=1:itr for i=2:nx-1 for j=2:ny-1 T(j,i)=((T(j-1,i)+T(j+1,i)+T(j,i-1)+T(j,i+1))/4) end end end [Xq Yq]= meshgrid(linspace(0,5,nx*10),linspace(0,5,ny*10));colormap jetVq=interp2(X,Y,T,Xq,Yq,'cubic',0);
This is my code. My iteration 200 but i want my code stop when Tn(j,i)=Tn+1(j,i) . But i dont know how to break for end…
Best Answer