MATLAB Answers

How to use the streamline function for a circular area?

2 views (last 30 days)
Xinchen Zhang
Xinchen Zhang on 14 Oct 2019
Commented: Xinchen Zhang on 14 Oct 2019
Hi all,
Let's say, 'x' and 'y' in the mat file are the coordinate of the circular area, consist of 64 ununiformly distributed points on radial lines and 180 uniformly distributed angles. 'ux' and 'uy' in the mat file are the velocity on x and y directions. But when I use 'streamline(x,y,ux,uy,0.1,0.1)' or 'stream2(x,y,ux,uy,0.1,0.1)' to plot the streamline of the circular area, it always gives me the error message
"Error using griddedInterpolant
Interpolation requires at least two sample points in each dimension."
So I would like to know how to use the streamline function for a circular area.
Thank all in advance, any advice would be much appreciated.


Sign in to comment.

Accepted Answer

darova on 14 Oct 2019
You can just make new grid/mesh for your data (standard rectangular, corners are NaN)
Here is a way:
load test.mat
[m,n] = size(x);
x1 = linspace( min(x(:)), max(x(:)), 50 ); % x boundary
y1 = linspace( min(y(:)), max(y(:)), 50 ); % y boundary
[X,Y] = meshgrid(x1,y1); % new mesh
U = griddata(x,y,Ux,X,Y); % new Ux
V = griddata(x,y,Uy,X,Y); % new Uy
t = linspace(0,2*pi,20);
[sx1,sy1] = pol2cart(t,5e-3); % start points
streamline(X,Y,U,V, sx1, sy1)
hold on
plot(sx1,sy1,'*r') % start points of streamlines
plot(x(end,:),y(end,:),'.-r') % boundary of a region
hold off
axis equal

  1 Comment

Sign in to comment.

More Answers (0)

Sign in to answer this question.