Generate a Grid from Nodes Coordinates

35 visualizzazioni (ultimi 30 giorni)
Mahe
Mahe il 1 Set 2015
Risposto: Tim Jackman il 3 Set 2015
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

Risposte (1)

Tim Jackman
Tim Jackman il 3 Set 2015
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);

Community Treasure Hunt

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

Start Hunting!

Translated by