Borrar filtros
Borrar filtros

Create Streamlines with Curvilinear Grid

6 visualizaciones (últimos 30 días)
Cas Cas
Cas Cas el 3 de Ag. de 2021
Comentada: Cas Cas el 16 de Ag. de 2021
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 comentarios
KSSV
KSSV el 4 de Ag. de 2021
The attached mat file has (x,y) points of dimensions 268*955; the respective velcoity fields are not given.
Cas Cas
Cas Cas el 4 de Ag. de 2021
Editada: Cas Cas el 4 de Ag. de 2021
@KSSV Shoot. Thanks for noticing. I had updated the .mat file but forgotten to replace it here.
Updated now. 22 x 31 grid.

Iniciar sesión para comentar.

Respuesta aceptada

KSSV
KSSV el 4 de Ag. de 2021
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 comentarios
KSSV
KSSV el 12 de Ag. de 2021
You need to map them to a grid to my knowledge.
Cas Cas
Cas Cas el 16 de Ag. de 2021
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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Surface and Mesh Plots en Help Center y File Exchange.

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by