How to change for loop to flip graph?

1 view (last 30 days)
T.A.S.
T.A.S. on 12 Mar 2019
Answered: Cris LaPierre on 13 Mar 2019
How do i change my code to get my graph to flip so that the contour lines start at 0.05 and go down, also with the vector lines?
Vo=zeros(6,11);
V(1,:)=V(1,:)+100;
n=1;
k=0;
h = 0.01;
g = 0;
while k==0
Vo=V;
k=1;
for i=2:5
for j=2:10
V(i,j)=(Vo(i+1,j)+V(i-1,j)+V(i,j-1)+Vo(i,j+1)+ h^2*g)/4;
if abs((V(i,j)-Vo(i,j)))>(10^-5)
k=0;
end
end
end
n=n+1;
end
n;
x=0:0.01:0.1;
y=0:0.01:0.05;
[px,py] = gradient(V);
figure
contour (x,y,V)
hold on
quiver(x,y,px,py)
hold off

Answers (1)

Cris LaPierre
Cris LaPierre on 13 Mar 2019
We don't have your variable V so I can't verify, but would adding this to the end of your code do it?
ax=gca;
ax.YDir = 'reverse'

Categories

Find more on Vector Fields in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!