How to use the streamline function for a circular area?

34 ビュー (過去 30 日間)
Xinchen Zhang
Xinchen Zhang 2019 年 10 月 14 日
コメント済み: Xinchen Zhang 2019 年 10 月 14 日
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.

採用された回答

darova
darova 2019 年 10 月 14 日
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
  1 件のコメント
Xinchen Zhang
Xinchen Zhang 2019 年 10 月 14 日
It works perfectly. Many thanks darova.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeEnvironment and Clutter についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by