MATLAB Answers

# How to plot for physical bodys and streamlines?

10 views (last 30 days)
David Scidmore on 13 Feb 2021
Answered: Pratyush Roy on 16 Feb 2021
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 CommentShowHide None
dpb on 13 Feb 2021
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.

Sign in to comment.

### Answers (1)

Pratyush Roy on 16 Feb 2021
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!
##### 0 CommentsShowHide -1 older comments

Sign in to comment.

### Community Treasure Hunt

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

Start Hunting!