Streamline Not Displaying On 2D Vector Field

조회 수: 5 (최근 30일)
Justin Purser
Justin Purser 2023년 2월 2일
댓글: Justin Purser 2023년 2월 4일
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
KSSV
KSSV 2023년 2월 2일
You can try streamslice.
Justin Purser
Justin Purser 2023년 2월 4일
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.

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Volume Visualization에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by