Streamline Not Displaying On 2D Vector Field

5 views (last 30 days)
I am trying to plot a streamline of a negative 2D vector field. When I plot the positive version of the equation, I get this:
Okay, great. Now to change the V_0 variable from 1 to -1:
Despite messing with startx and starty to try and make it plot, I cannot figure it out. Using the Plot Browser, there is clearly something there, but it looks like an array of independent data points instead of a line curve:
Footnote: I acknowledge the clunkiness of two startxs and two plot commands, but when one startx and plot command are alone, streamlines only plot on one side of x = 0. Code:
Any help greatly appreciated.
V_0 = -1; % When this is positive, I get the first graph image. When it is negative, I get the second.
L = 2;
x = (-1:0.1:1);
y = (0:0.1:1);
[X,Y] = meshgrid(x,y);
u = (V_0/L)*(-2*X);
v = (V_0/L)*(Y);
quiver(X,Y,u,v);
starty = (-2:0.025:2); % I know the issue exsits with this
startx1 = ones(size(starty)); % and/or this
hold on
streamline(X,Y,u,v,startx1,starty)
startx2 = ones(size(starty))*min(x); % and/or this, but cannot determine the issue. This code generates no errors.
streamline(X,Y,u,v,startx2,starty)
  2 Comments
Justin Purser
Justin Purser on 4 Feb 2023
KSSV,
Thank you. That actually worked really easily.
After revisiting my previous code, a slightly clunkier method was to define the meshgrid for startx and starty.
...
starty = (-2:0.025:2);
startx1 = ones(size(starty));
[startx1,starty] = meshgrid(-1:0.1:1,0:0.1:1);
hold on
...
Thanks again for your help.

Sign in to comment.

Answers (0)

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!