Error using streamline function in matlab
7 views (last 30 days)
Show older comments
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)
0 Comments
Answers (2)
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)
0 Comments
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.
.
0 Comments
See Also
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!