Error using streamline function in matlab

7 views (last 30 days)
mukesh bisht
mukesh bisht on 16 Jul 2021
Edited: Cris LaPierre on 16 Jul 2021
Hi
I am trying to plot the velocity vector and streamline from the data (file attached). The "quiver" function plots the velcoity vector but when I use "Streamline" function for the same data the figure shows no streamlines.
Attached Figure1 for velcoity vector, Figure2 for streamline plot
Code:
quiver(X,Z,U,W)
streamline(X,Z,U,W,startx,startz)

Answers (2)

Cris LaPierre
Cris LaPierre on 16 Jul 2021
Edited: Cris LaPierre on 16 Jul 2021
Make sure your starting points are inside the vector field, and streamlines will plot.
load mukeshbisht_matlab.mat
quiver(X,Z,U,W)
startx = -2.9:.1:-1;
starty = 1:0.1:2.9;
hold on
plot(startx,starty,'rx')
hold off
axis equal
figure
streamline(X,Z,U,W,startx,starty)

Star Strider
Star Strider on 16 Jul 2021
The ‘startx’ vector is incorrect.
Try this —
LD = load('mukesh bisht matlab.mat');
U = LD.U;
W = LD.W;
X = LD.X;
Z = LD.Z;
% startx = LD.startx; % Incorrect Values
startz = LD.startz;
startx = X(1,:).'; % Working Values
figure
quiver(X,Z,U,W)
hold on
streamline(X,Z,U,W,startx,startz)
hold off
axis('equal')
The plot is still not exactly what I would expect, however it is definitely closer to the desired result.
.

Categories

Find more on Vector Fields in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!