Pressure contour

Hey all,

Baiscally, I want to calculate the pressure for square obstacles and I did this sub-routine (using MATLAB) but the results were not correct

P_vector=reshape(rho,Nx,Ny)/3; % Pressure contour
for j=1:Ny
for i=1:Nx
P(i,j)=P_vector((i-1)*Ny+j);
if P(i,j)==0
P(i,j)=nan;
end
end
end

Could anyone helps to figure out what is the mistake or have another idea or I might do mistake in this routine.

Cheers,
William