How to plot for physical bodys and streamlines?

조회 수: 6 (최근 30일)
David Scidmore
David Scidmore 2021년 2월 13일
답변: Pratyush Roy 2021년 2월 16일
I'm trying to plot a streamline and am learning MatLAB as I go along (coding is definately not for me) for my class. I have the code below, but I end up with figure below. This happens to me no matter what I plot. I'm curious if I'm missing something in order to get lines to show up? I am trying to get a image similar to the bottom one.
x = [0:10];
y = [0:5];
E = 2.50;
U = 1;
TV = 1;
Pi=3.14;
Psi = E/2;
Psist = -E/(2*pi*U);
R = (E/2*Pi*U)*((Pi-TV)/sin(TV));
u = U + (E/2*pi*R)*cos(TV);
v = (E/2*pi*R)*sin(TV);
plot(u,v)
  댓글 수: 1
dpb
dpb 2021년 2월 13일
You never evaluate the correlation over x, y -- you define a vector of values for each but never reference either anywhere else.
So, your u, v values are only a single value and one pixel point is generally just too small to show up on the screen. You did plot one point, you just can't see it. Try
plot(u,v,'*')
to prove that.
To evaluate the values over a x,y grid such as your figure, you need to evaluate the functional at a bunch of points across both x and y although since this is symmetric around y==0, you could compute just one side there and reflect it around the y axis. Altogether, it's probably simpler to just compute it all directly. You will need to build in some logic for the branch points, though.
See
doc meshgrid
example for plotting a surface for an example of similar kind of thing over the x-y plane although note that with R2016b and latter implicit expansion can save explicit calculation of the full XY mesh.

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

답변 (1개)

Pratyush Roy
Pratyush Roy 2021년 2월 16일
Hi David,
As rightly pointed out, the plot only displays a point since u and v values are not arrays but single points.
To obtain a 2D streamline plot, you might need the arrays containing positions(x,y), directional components(u,v) at those points as well as the starting positions of the streamlines. The documentation link for streamline might be helpful.
Hope this helps!

카테고리

Help CenterFile Exchange에서 Vector Fields에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by