Generate a Grid from Nodes Coordinates

9 次查看(过去 30 天)
Hey,
I have four vectors, the first contains my X-Coordinates, the second the Y-Coordinates, the third my U-Velocity and the fourth my V-Velocity.
In order to use plot functions as curl, ncquiverref and so on, I need to transform the Node information stored in the vectors to a matrix form.
Bascially I want to do what Quiver is doing when I use quiver(X,Y,U,V). However so far I am not able to do this.
I tried meshgrid but it doesn't work, since it gives me a 10 by 10 grid for 10 Nodes in the vectors.(most values appear more than once)
If somebody has a good a idea or knows a command I would greatly appreciate it!!
Mahe

回答(1 个)

Tim Jackman
Tim Jackman 2015-9-3
It sounds like you need to convert your vectors of locations and velocities into gridded data, correct? One way to do this would be with the griddata command. For example, given some x and y locations ranging from 0 to 100 and the corresponding velocities u and v:
x = rand(100,1)*100;
y = rand(100,1)*100;
v = rand(100,1);
u = rand(100,1);
you can create a meshgrid of the x and y locations such that the meshgrid domain covers all possible x and y locations from your original data. Then use griddata to interpolate the scattered data onto the grid.
[xgrid,ygrid] = meshgrid(1:0.5:100,1:0.5:100);
vq = griddata(x,y,v,xgrid,ygrid);
uq = griddata(x,y,u,xgrid,ygrid);

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by