How to change for loop to flip graph?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/208150/image.png)
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
0 comentarios
Respuestas (1)
Cris LaPierre
el 13 de Mzo. de 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'
0 comentarios
Ver también
Categorías
Más información sobre Contour Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!