How to use the streamline function for a circular area?

34 visualizaciones (últimos 30 días)
Xinchen Zhang
Xinchen Zhang el 14 de Oct. de 2019
Comentada: Xinchen Zhang el 14 de Oct. de 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.

Respuesta aceptada

darova
darova el 14 de Oct. de 2019
You can just make new grid/mesh for your data (standard rectangular, corners are NaN)
Here is a way:
clc,clear
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
cla
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

Más respuestas (0)

Categorías

Más información sobre Environment and Clutter en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by