BillyJean
BillyJean

Reputation: 1587

Streamlines not being displayed in MATLAB

I am trying to plot streamlines following the documentation. My data is in the meshgrid-format as described there.

However, when I try to plot it using streamline(x,y,vx,vy) all I get is an empty figure ranging from 0 to 1. When I add starting points, it is still blankstreamline(x,y,vx,vy, 1:5,0*(1:5)).

What am I missing to get the streamlines plotted?

Here is my data:

x =  [0         0.0125    0.0250    0.0375    0.0500,
      0         0.0125    0.0250    0.0375    0.0500,
      0         0.0125    0.0250    0.0375    0.0500,
      0         0.0125    0.0250    0.0375    0.0500,
      0         0.0125    0.0250    0.0375    0.0500];

y =  [0         0         0         0         0,
      0.0125    0.0125    0.0125    0.0125    0.0125,
      0.0250    0.0250    0.0250    0.0250    0.0250,
      0.0375    0.0375    0.0375    0.0375    0.0375,
      0.0500    0.0500    0.0500    0.0500    0.0500];

vx = [0.0009   -0.0019   -0.0058   -0.0040   -0.0028,
      0.0012    0.0159    0.1207    0.1465    0.0985,
      0.0007    0.0018   -0.0367    0.2432   -0.0053,
      0.0004    0.0920    0.1796    0.3807    0.0338,
     -0.0006    0.1708    0.1764    0.2567    0.1256];

vy = [0.0002    0.0000   -0.0001   -0.0001   -0.0001,
     -0.0003   -0.0156   -0.0076   -0.0251   -0.0433,
     -0.0008   -0.0113   -0.0218   -0.0519   -0.0720,
     -0.0006   -0.0091   -0.0326   -0.0778   -0.1087,
     -0.0003   -0.0026   -0.0025   -0.0416   -0.1048];

Upvotes: 0

Views: 1106

Answers (1)

Matt
Matt

Reputation: 13943

Your provided range is not correct because you want to plot x in the range from 1 to 5 when your data contains values for x in the range from 0 to 0.5.

If you set your starting points to something more reasonable, you will get the streamlines as expected. We can for example use x = 0.015 and y = 0.01 ... 0.05 as in the example below:

streamline(x,y,vx,vy, ones(1,5)*0.015, 0.01:0.01:0.05);

result


To get an impression on where you could set your starting points, you can use quiver. Then you see arrows representing the velocity at the defined points in the dataset. Depending on that you can decide which starting points to use.

quiver(x,y,vx,vy);

quiver-plot

Upvotes: 2

Related Questions