How to change for loop to flip graph?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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
0 commentaires
Réponses (1)
Cris LaPierre
le 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'
0 commentaires
Voir également
Catégories
En savoir plus sur Vector Fields dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!