Contour Plot Flow Direction

조회 수: 3 (최근 30일)
Ali Alkoraishi
Ali Alkoraishi 2020년 4월 15일
편집: Adam Danz 2020년 4월 17일
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
darova
darova 2020년 4월 15일
Can you attach something more? The data, code
Ali Alkoraishi
Ali Alkoraishi 2020년 4월 15일
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);

댓글을 달려면 로그인하십시오.

채택된 답변

Adam Danz
Adam Danz 2020년 4월 15일
Follow this demo. If you get stuck, show us what you've got and we can help you get un-stuck.
  댓글 수: 4
Ali Alkoraishi
Ali Alkoraishi 2020년 4월 16일
This is the output I am getting and its uniform and flowing in the wrong directions, thanks
Adam Danz
Adam Danz 2020년 4월 16일
편집: Adam Danz 2020년 4월 17일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Vector Fields에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by