Contour Plot Flow Direction

1 visualización (últimos 30 días)
Ali Alkoraishi
Ali Alkoraishi el 15 de Abr. de 2020
Editada: Adam Danz el 17 de Abr. de 2020
How can i plot a quiver plot on top of this to indicate the flow direction. The blue circles are wells and flow is supposed to go downstream.
  2 comentarios
darova
darova el 15 de Abr. de 2020
Can you attach something more? The data, code
Ali Alkoraishi
Ali Alkoraishi el 15 de Abr. de 2020
clc;clear all;close all
% x and y coordinates of well locations and lake points in cm (3.4cm/km)
w1=[5.9,5.6];
w8=[8,7.6];
w17=[11.9,2];
w21=[9.7,5.3];
w27=[4.6,4.6];
w56=[5.9,1.7];
w58=[5.9,1];
w59=[6.7,4.1];
lakepoint1=[4,6.55];
lakepoint2=[5.75,6.9];
lakepoint3=[7.7,7.65];
% Combined coordinates into a single matrix
wells=[w1;w8;w17;w21;w27;w56;w58;w59;lakepoint1;lakepoint2;lakepoint3];
% Converted well locations to metres
scaledwells=wells*0.441176*1000;
%Groundwater table elevations at each well and at 3 points of the lake. (in metres)
gwtablew1=236.07;
gwtablew8=236.65;
gwtablew17=240.37;
gwtablew21=238.13;
gwtablew27=235.96;
gwtablew56=236.66;
gwtablew58=237.70;
gwtablew59=237.90;;
gwtablelake1=234.19;
gwtablelake2=234.19;
gwtablelake3=234.19;
%Combined into single matrix below
gwtable=[gwtablew1;gwtablew8;gwtablew17;gwtablew21;gwtablew27;gwtablew56;gwtablew58;gwtablew59;gwtablelake1;gwtablelake2;gwtablelake3];
%created scatter plot of x and y coordinates of wells and lake points)
scatter(scaledwells(:,1),scaledwells(:,2))
xlabel('m')
ylabel('m')
grid on
hold on
%Trying to produce contours
scaledwellsx=scaledwells(:,1);
scaledwellsy=scaledwells(:,2);
[X,Y] = meshgrid(sort(scaledwellsx), sort(scaledwellsy));
F = scatteredInterpolant(scaledwellsx,scaledwellsy,gwtable);
Z = F(X,Y);
contour_levels = min(Z,[],'all'):0.2:max(Z,[],'all');
contour(X, Y, Z, contour_levels);

Iniciar sesión para comentar.

Respuesta aceptada

Adam Danz
Adam Danz el 15 de Abr. de 2020
Follow this demo. If you get stuck, show us what you've got and we can help you get un-stuck.
  4 comentarios
Ali Alkoraishi
Ali Alkoraishi el 16 de Abr. de 2020
This is the output I am getting and its uniform and flowing in the wrong directions, thanks
Adam Danz
Adam Danz el 16 de Abr. de 2020
Editada: Adam Danz el 17 de Abr. de 2020
To create a grid of quiver arrows that flow down hill rather than up hill,
% Grid interp
Xs = linspace(min(scaledwellsx), max(scaledwellsx),20);
Ys = linspace(min(scaledwellsy), max(scaledwellsy),20);
[Xq, Yq] = meshgrid(Xs,Ys);
Vq = F(Xq,Yq);
% Plot quiver grid
% Negate Vq to reverse polarity of vectors
[U,V] = gradient(-Vq);
hold on
h = quiver(Xq,Yq,U,V,2, 'k') % The 2 is a scaling factor
Notice that gradient(-Vq) reverses the direction of the arrows. You could also try gradient(1./Vq) or use quiverRotate() from the file exchange.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Vector Fields 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!

Translated by