Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Help with streamline

Subject: Help with streamline

From: pmassicotte

Date: 20 Oct, 2011 00:16:15

Message: 1 of 4

Hi everyone.

I have a vector field (x,y,u,v) describing the displacement of water
in a river.

I would like to know if there is a way to plot streamlines on such
vector field. In other words, I would like to select a point upstream
and find the pathway accordingly to the vector field.

Here's my code:

[X Y] = meshgrid(xyuv(:,1), xyuv(:,2));
[U V] = meshgrid(xyuv(:,3), xyuv(:,4));
%quiver plot (x,y,u,v)
quiver(xyuv2(:,1), xyuv2(:,2),xyuv(:,3), xyuv(:,4));
streamline(X,Y,U,V,645254.836600000,5106090.77400000);

The quiver plot show that my data are correct. However, the streamline
function does not seems to work. I cant find where I'm making mistake.

The data is provided bellow.

Regards,
Phil

645254.836600000 5106090.77400000 0.593600000000000 0.659100000000000
645262.421100000 5106060.14500000 0.544900000000000 0.640400000000000
645230.366300000 5106063.39100000 0.574800000000000 0.653300000000000
645284.905400000 5106085.95000000 0.569300000000000 0.671700000000000
645280.119400000 5106119.06700000 0.610300000000000 0.681800000000000
645298.231700000 5106050.09700000 0.524600000000000 0.674700000000000
645324.751600000 5106019.92100000 0.516600000000000 0.687600000000000
645366.790500000 5106021.84500000 0.520800000000000 0.683900000000000
645322.580900000 5105964.37200000 0.541700000000000 0.703600000000000
645280.633000000 5105992.62600000 0.514300000000000 0.650000000000000
645246.369000000 5106022.09700000 0.525400000000000 0.609300000000000
645210.623600000 5106041.29800000 0.586000000000000 0.609000000000000
645304.403700000 5106146.24200000 0.628900000000000 0.703600000000000
645319.979400000 5106105.56300000 0.582700000000000 0.701500000000000
645353.263600000 5106069.61200000 0.527200000000000 0.691200000000000
645405.413700000 5106072.05500000 0.524900000000000 0.659100000000000
645288.685200000 5105920.30800000 0.529900000000000 0.689700000000000
645263.456300000 5105938.43200000 0.518800000000000 0.658900000000000
645229.299200000 5105964.37700000 0.494900000000000 0.588400000000000
645203.385500000 5105991.35300000 0.515000000000000 0.564600000000000
645162.007800000 5105992.68200000 0.542800000000000 0.536600000000000
645325.631000000 5106169.99700000 0.629700000000000 0.705300000000000
645342.599000000 5106150.16900000 0.630700000000000 0.705800000000000
645367.653100000 5106121.48700000 0.595100000000000 0.698400000000000
645401.602100000 5106103.71200000 0.557700000000000 0.664400000000000
645422.591100000 5106091.80900000 0.546800000000000 0.615900000000000
645255.442500000 5105877.09200000 0.520500000000000 0.672900000000000
645225.607400000 5105838.30700000 0.465500000000000 0.628200000000000
645211.446700000 5105908.25500000 0.499200000000000 0.580900000000000
645171.311000000 5105939.44100000 0.484000000000000 0.517500000000000
645122.588100000 5105953.26300000 0.514100000000000 0.517500000000000
645349.510100000 5106196.71800000 0.628300000000000 0.701700000000000
645380.331400000 5106167.33300000 0.633000000000000 0.717000000000000
645412.909600000 5106139.96700000 0.583400000000000 0.683300000000000
645443.685400000 5106116.06700000 0.519700000000000 0.598800000000000
645195.229200000 5105854.40600000 0.490000000000000 0.582600000000000
645200.371400000 5105805.50000000 0.494300000000000 0.549500000000000
645154.877600000 5105877.11000000 0.470800000000000 0.529400000000000
645116.855400000 5105902.09100000 0.457900000000000 0.501800000000000
645090.968300000 5105921.64300000 0.482600000000000 0.483000000000000
645375.084500000 5106225.33700000 0.626900000000000 0.702100000000000
645394.026100000 5106207.00200000 0.639900000000000 0.719100000000000
645421.378900000 5106181.88200000 0.622800000000000 0.720600000000000
645449.852300000 5106158.06700000 0.549000000000000 0.656500000000000
645466.933600000 5106142.80300000 0.502200000000000 0.576400000000000
645158.689600000 5105763.81800000 0.526300000000000 0.518100000000000
645139.442400000 5105813.70200000 0.526700000000000 0.520600000000000
645096.345400000 5105847.37300000 0.488200000000000 0.497000000000000
645055.037600000 5105885.71200000 0.452000000000000 0.449100000000000
645018.630700000 5105849.30500000 0.390500000000000 0.387600000000000
645128.738700000 5105733.86700000 0.579800000000000 0.585300000000000
645401.123000000 5106254.47600000 0.629200000000000 0.703000000000000
645431.377500000 5106222.26700000 0.649500000000000 0.734300000000000
645441.800800000 5106256.32200000 0.626400000000000 0.751500000000000
645462.013200000 5106194.28500000 0.603200000000000 0.693000000000000
645489.505400000 5106168.76000000 0.485300000000000 0.560200000000000
645104.896300000 5105756.68200000 0.489900000000000 0.564900000000000
645071.376900000 5105787.02400000 0.485500000000000 0.545100000000000
645040.205400000 5105822.50500000 0.435500000000000 0.513200000000000
644985.664500000 5105816.33900000 0.341300000000000 0.349300000000000
644944.338900000 5105775.01400000 0.363900000000000 0.334100000000000
645099.447600000 5105704.57600000 0.632100000000000 0.631300000000000
645469.332200000 5106275.24100000 0.653800000000000 0.728300000000000
645437.817400000 5106295.53900000 0.669000000000000 0.747800000000000
645500.134600000 5106292.01800000 0.648800000000000 0.765300000000000
645471.047100000 5106235.94700000 0.615700000000000 0.736800000000000
645493.158200000 5106262.97800000 0.646100000000000 0.749900000000000
645492.437200000 5106209.51500000 0.564200000000000 0.653900000000000
645511.210000000 5106193.72100000 0.480500000000000 0.552500000000000
645046.740800000 5105722.45200000 0.503100000000000 0.505200000000000
645004.087300000 5105762.44500000 0.515300000000000 0.502200000000000
644949.481700000 5105728.78900000 0.409400000000000 0.462300000000000
644892.808200000 5105723.48300000 0.247000000000000 0.359500000000000
645062.744800000 5105667.87300000 0.615400000000000 0.639900000000000
645479.462200000 5106310.89400000 0.640900000000000 0.742800000000000
645464.231100000 5106325.09700000 0.690300000000000 0.772400000000000
645512.872900000 5106322.71700000 0.630500000000000 0.778700000000000
645528.084100000 5106301.35200000 0.629400000000000 0.759500000000000
645520.577900000 5106274.17800000 0.623100000000000 0.736300000000000
645507.087600000 5106241.47600000 0.558600000000000 0.684000000000000
645532.856100000 5106218.61400000 0.477500000000000 0.549700000000000
644884.629800000 5105689.74600000 0.0790000000000000 0.509300000000000
645017.106300000 5105670.34800000 0.545600000000000 0.580200000000000
644978.360800000 5105692.22400000 0.428200000000000 0.571700000000000
644922.337900000 5105685.65700000 0.255700000000000 0.543100000000000
645022.293000000 5105627.42200000 0.716500000000000 0.628800000000000

Subject: Help with streamline

From: pmassicotte

Date: 26 Oct, 2011 11:11:55

Message: 2 of 4

On Oct 19, 8:16 pm, pmassicotte <pmassico...@hotmail.com> wrote:
> Hi everyone.
>
> I have a vector field (x,y,u,v) describing the displacement of water
> in a river.
>
> I would like to know if there is a way to plot streamlines on such
> vector field. In other words, I would like to select a point upstream
> and find the pathway accordingly to the vector field.
>
> Here's my code:
>
> [X Y] = meshgrid(xyuv(:,1), xyuv(:,2));
> [U V] = meshgrid(xyuv(:,3), xyuv(:,4));
> %quiver plot (x,y,u,v)
> quiver(xyuv2(:,1), xyuv2(:,2),xyuv(:,3), xyuv(:,4));
> streamline(X,Y,U,V,645254.836600000,5106090.77400000);
>
> The quiver plot show that my data are correct. However, the streamline
> function does not seems to work. I cant find where I'm making mistake.
>
> The data is provided bellow.
>
> Regards,
> Phil
>
> 645254.836600000        5106090.77400000        0.593600000000000       0.659100000000000
> 645262.421100000        5106060.14500000        0.544900000000000       0.640400000000000
> 645230.366300000        5106063.39100000        0.574800000000000       0.653300000000000
> 645284.905400000        5106085.95000000        0.569300000000000       0.671700000000000
> 645280.119400000        5106119.06700000        0.610300000000000       0.681800000000000
> 645298.231700000        5106050.09700000        0.524600000000000       0.674700000000000
> 645324.751600000        5106019.92100000        0.516600000000000       0.687600000000000
> 645366.790500000        5106021.84500000        0.520800000000000       0.683900000000000
> 645322.580900000        5105964.37200000        0.541700000000000       0.703600000000000
> 645280.633000000        5105992.62600000        0.514300000000000       0.650000000000000
> 645246.369000000        5106022.09700000        0.525400000000000       0.609300000000000
> 645210.623600000        5106041.29800000        0.586000000000000       0.609000000000000
> 645304.403700000        5106146.24200000        0.628900000000000       0.703600000000000
> 645319.979400000        5106105.56300000        0.582700000000000       0.701500000000000
> 645353.263600000        5106069.61200000        0.527200000000000       0.691200000000000
> 645405.413700000        5106072.05500000        0.524900000000000       0.659100000000000
> 645288.685200000        5105920.30800000        0.529900000000000       0.689700000000000
> 645263.456300000        5105938.43200000        0.518800000000000       0.658900000000000
> 645229.299200000        5105964.37700000        0.494900000000000       0.588400000000000
> 645203.385500000        5105991.35300000        0.515000000000000       0.564600000000000
> 645162.007800000        5105992.68200000        0.542800000000000       0.536600000000000
> 645325.631000000        5106169.99700000        0.629700000000000       0.705300000000000
> 645342.599000000        5106150.16900000        0.630700000000000       0.705800000000000
> 645367.653100000        5106121.48700000        0.595100000000000       0.698400000000000
> 645401.602100000        5106103.71200000        0.557700000000000       0.664400000000000
> 645422.591100000        5106091.80900000        0.546800000000000       0.615900000000000
> 645255.442500000        5105877.09200000        0.520500000000000       0.672900000000000
> 645225.607400000        5105838.30700000        0.465500000000000       0.628200000000000
> 645211.446700000        5105908.25500000        0.499200000000000       0.580900000000000
> 645171.311000000        5105939.44100000        0.484000000000000       0.517500000000000
> 645122.588100000        5105953.26300000        0.514100000000000       0.517500000000000
> 645349.510100000        5106196.71800000        0.628300000000000       0.701700000000000
> 645380.331400000        5106167.33300000        0.633000000000000       0.717000000000000
> 645412.909600000        5106139.96700000        0.583400000000000       0.683300000000000
> 645443.685400000        5106116.06700000        0.519700000000000       0.598800000000000
> 645195.229200000        5105854.40600000        0.490000000000000       0.582600000000000
> 645200.371400000        5105805.50000000        0.494300000000000       0.549500000000000
> 645154.877600000        5105877.11000000        0.470800000000000       0.529400000000000
> 645116.855400000        5105902.09100000        0.457900000000000       0.501800000000000
> 645090.968300000        5105921.64300000        0.482600000000000       0.483000000000000
> 645375.084500000        5106225.33700000        0.626900000000000       0.702100000000000
> 645394.026100000        5106207.00200000        0.639900000000000       0.719100000000000
> 645421.378900000        5106181.88200000        0.622800000000000       0.720600000000000
> 645449.852300000        5106158.06700000        0.549000000000000       0.656500000000000
> 645466.933600000        5106142.80300000        0.502200000000000       0.576400000000000
> 645158.689600000        5105763.81800000        0.526300000000000       0.518100000000000
> 645139.442400000        5105813.70200000        0.526700000000000       0.520600000000000
> 645096.345400000        5105847.37300000        0.488200000000000       0.497000000000000
> 645055.037600000        5105885.71200000        0.452000000000000       0.449100000000000
> 645018.630700000        5105849.30500000        0.390500000000000       0.387600000000000
> 645128.738700000        5105733.86700000        0.579800000000000       0.585300000000000
> 645401.123000000        5106254.47600000        0.629200000000000       0.703000000000000
> 645431.377500000        5106222.26700000        0.649500000000000       0.734300000000000
> 645441.800800000        5106256.32200000        0.626400000000000       0.751500000000000
> 645462.013200000        5106194.28500000        0.603200000000000       0.693000000000000
> 645489.505400000        5106168.76000000        0.485300000000000       0.560200000000000
> 645104.896300000        5105756.68200000        0.489900000000000       0.564900000000000
> 645071.376900000        5105787.02400000        0.485500000000000       0.545100000000000
> 645040.205400000        5105822.50500000        0.435500000000000       0.513200000000000
> 644985.664500000        5105816.33900000        0.341300000000000       0.349300000000000
> 644944.338900000        5105775.01400000        0.363900000000000       0.334100000000000
> 645099.447600000        5105704.57600000        0.632100000000000       0.631300000000000
> 645469.332200000        5106275.24100000        0.653800000000000       0.728300000000000
> 645437.817400000        5106295.53900000        0.669000000000000       0.747800000000000
> 645500.134600000        5106292.01800000        0.648800000000000       0.765300000000000
> 645471.047100000        5106235.94700000        0.615700000000000       0.736800000000000
> 645493.158200000        5106262.97800000        0.646100000000000       0.749900000000000
> 645492.437200000        5106209.51500000        0.564200000000000       0.653900000000000
> 645511.210000000        5106193.72100000        0.480500000000000       0.552500000000000
> 645046.740800000        5105722.45200000        0.503100000000000       0.505200000000000
> 645004.087300000        5105762.44500000        0.515300000000000       0.502200000000000
> 644949.481700000        5105728.78900000        0.409400000000000       0.462300000000000
> 644892.808200000        5105723.48300000        0.247000000000000       0.359500000000000
> 645062.744800000        5105667.87300000        0.615400000000000       0.639900000000000
> 645479.462200000        5106310.89400000        0.640900000000000       0.742800000000000
> 645464.231100000        5106325.09700000        0.690300000000000       0.772400000000000
> 645512.872900000        5106322.71700000        0.630500000000000       0.778700000000000
> 645528.084100000        5106301.35200000        0.629400000000000       0.759500000000000
> 645520.577900000        5106274.17800000        0.623100000000000       0.736300000000000
> 645507.087600000        5106241.47600000        0.558600000000000       0.684000000000000
> 645532.856100000        5106218.61400000        0.477500000000000       0.549700000000000
> 644884.629800000        5105689.74600000        0.0790000000000000      0.509300000000000
> 645017.106300000        5105670.34800000        0.545600000000000       0.580200000000000
> 644978.360800000        5105692.22400000        0.428200000000000       0.571700000000000
> 644922.337900000        5105685.65700000        0.255700000000000       0.543100000000000
> 645022.293000000        5105627.42200000        0.716500000000000       0.628800000000000

Hi everyone. I'm still looking to resolve this issue. If anyone has
suggestions, let me know.

Regards,
Phil

Subject: Help with streamline

From: Armin Mueller

Date: 27 Oct, 2011 13:44:43

Message: 3 of 4

pmassicotte wrote:

> The quiver plot show that my data are correct. However, the streamline
> function does not seems to work. I cant find where I'm making mistake.

The data is correct. However, the results of meshgrid() are probably not
what you want. Try

quiver(X, Y, U, V)

:-/
Armin

Subject: Help with streamline

From: Armin Mueller

Date: 27 Oct, 2011 14:06:37

Message: 4 of 4

Armin Mueller wrote:

> The data is correct. However, the results of meshgrid() are probably not
> what you want.

How about this? The data is first resampled to lie on a rectangular
grid, which can then be used for streamline(). Your favorite starting
point seems to be off the grid, however. And interpolation results in
some error, too.

:-)
Armin


%% quiver plot (x,y,u,v)
figure
quiver(xyuv(:,1), xyuv(:,2), xyuv(:,3), xyuv(:,4))
axis equal

%% streamline plot
x = xyuv(:, 1);
y = xyuv(:, 2);
u = xyuv(:, 3);
v = xyuv(:, 4);

xrect = linspace(min(xyuv(:,1)), max(xyuv(:,1)), 50);
yrect = linspace(min(xyuv(:,2)), max(xyuv(:,2)), 50);

[XI,YI] = meshgrid(xrect, yrect);

UI = griddata(x, y, u, XI, YI);
VI = griddata(x, y, v, XI, YI);

figure
streamline(XI, YI, UI, VI, XI, YI)
axis equal

%% one streamline
figure
streamline(XI, YI, UI, VI, 645254.836600000, 5106090.77400000)
axis equal

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us