% In HW3 we use the myBC=4 i.e. Ttop = Tbot = 303K and Tleft=293K if(myBC == 1) Tleft = 393; Tright = 293; T(1,:) = T(2,:); T(Ny,:) = T(Ny-1,:); T(iny,1)= 2*Tleft - T(iny,2); T(iny,Nx)=2*Tright - T(iny,Nx-1); elseif(myBC == 4) Tleft = 293; Ttop = 303; Tbot = 303; % On these lines we copy to the ghost cells % rows Tghost = 2*Ttarget-Tinside to give exactly Ttarget between % ghost cell rows/columns and the first internal rows/columns % use 2nd/Ny-1 row data to enforce Ttop/Tbot on top/bottom wall T(1,:) = 2*Ttop - T(2,:); T(Ny,:) = 2*Tbot - T(Ny-1,:); % use 2nd column data (left end) to give Tleft at the inlet T(iny,1)= 2*Tleft - T(iny,2); % at the outlet, copy Nx-1 content to Nx row so dTdx = const T(iny,Nx)= T(iny,Nx-1); end