フィルターのクリア

Create Streamlines with Curvilinear Grid

6 ビュー (過去 30 日間)
Cas Cas
Cas Cas 2021 年 8 月 3 日
コメント済み: Cas Cas 2021 年 8 月 16 日
I have a curvilinear grid with [x,y,z] coordinates and location has [u,v,w] components representing a flow field.
I'm able to plot quiver plots and create animations of the vector fields but I'm trying to incorporate streamlines as well, and this is where I'm having trouble. I suspect the issue is my grid being curvilinear rather than rectilinear and uniform (although the help for streamline() suggests that points do not need to be uniform, so maybe I'm wrong).
I've been getting a couple of errors:
First, when I have NaNs in the data
Error using matlab.internal.math.interp1
The sample points must be finite.
Error in interp1 (line 154)
VqLite = matlab.internal.math.interp1(X,V,method,method,Xqcol);
Error in stream2 (line 62)
sxi=interp1(xx(:),1:szu(2),sx(k));
Error in streamline (line 62)
verts = stream2(x,y,u,v,sx,sy,options);
Alright, it's easier to work with NaNs but I can remove those from the data. I turn the [x,y,z] points that are NaN into zeroes and make sure my matrix and vector lengths remain okay. (I need an auto scale factor in the quiver plot now, though, which is a bit annoying).
Second, when I fix this, I get the following
Error using matlab.internal.math.interp1
Sample points must be unique and sorted in ascending order.
Error in interp1 (line 154)
VqLite = matlab.internal.math.interp1(X,V,method,method,Xqcol);
Error in stream2 (line 62)
sxi=interp1(xx(:),1:szu(2),sx(k));
Error in streamline (line 62)
verts = stream2(x,y,u,v,sx,sy,options);
Perhaps I'm interpreting this wrong, but when I check my startx and starty points, they are ascending and unique points.
I'm attaching an image of my grid: black dots represent the grid points, green arrows represent where [u,v,w] data exists, and red crosses are my starting points for my streamlines.
I'm also attaching a dataset: this dataset is a subset of my full grid for simplicity. The grid and vector fields do contain NaN values. In an attempt to circumvent the errors I'm getting, I turn all NaNs to 0. I would like to delete them altogether but then I would no longer have gridded data. Turning them to zeros though means that I need the scale factor in the code.
I've also attached my code (it's also how I made the figure).
Note for now until I get this going I'm focussing on 2D (i.e. x, y, u,and v).
  2 件のコメント
KSSV
KSSV 2021 年 8 月 4 日
The attached mat file has (x,y) points of dimensions 268*955; the respective velcoity fields are not given.
Cas Cas
Cas Cas 2021 年 8 月 4 日
編集済み: Cas Cas 2021 年 8 月 4 日
@KSSV Shoot. Thanks for noticing. I had updated the .mat file but forgotten to replace it here.
Updated now. 22 x 31 grid.

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

採用された回答

KSSV
KSSV 2021 年 8 月 4 日
load('streamline_help.mat')
x = gridx_subset ;
y = gridy_subset ;
u = u_subset ;
v = v_subset ;
% Remove nans
idx = ~isnan(x) ;
x = x(idx) ;
y = y(idx) ;
u = u(idx) ;
v = v(idx) ;
% convert data to grid data
m = 30 ; n = 30 ;
xi = linspace(min(x),max(x),m) ;
yi = linspace(min(y),max(y),n) ;
[X,Y] = meshgrid(xi,yi) ;
U = griddata(x,y,u,X,Y) ;
V = griddata(x,y,v,X,Y) ;
figure(1)
streamline(X,Y,U,V,X(1:2:end,1:2:end),Y(1:2:end,1:2:end))
  3 件のコメント
KSSV
KSSV 2021 年 8 月 12 日
You need to map them to a grid to my knowledge.
Cas Cas
Cas Cas 2021 年 8 月 16 日
Alright then. Thanks for your help. My question is answered, though my specific need isn't entirely addressed, but the workout we have will have to suffice, so I am accepting the answer. Cheers.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by