How to use the streamline function for a circular area?
조회 수: 34 (최근 30일)
이전 댓글 표시
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.
댓글 수: 0
채택된 답변
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Environment and Clutter에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!