Creating a grid from a 2D scatter plot of vectors
40 views (last 30 days)
Show older comments
So I have a list of x positions, y positions, x velocity and y velocity, I want to turn this in to 4 grid matrices with (i,j) from each of the 4 matrices corresponding to the values for x,y,u,v from the list above with the x, y values being in order in terms of their physical position. I have tried to just reshape the matrices but this isnt working and tried griddata but as I have two values for the velocity it wont work as v needs to be just a single value, and the velocity values are essentially random, so i can't create a fucntion that defines them over the domain, and if I get the resultant velocity vector this only defines the magnitude and not the direction.
I need to do this so I can do partial differentiation using the finite difference scheme. Does anyone have any suggestions as to how I might do this?
5 Comments
Accepted Answer
KSSV
on 22 Jun 2021
Let x, y, xvel, yvel be your data.
m = 100 ; n = 100;
x = linspace(min(x),max(x),m) ;
y = linspace(min(y),max(y),n) ;
[X,Y] = meshgrid(x,y) ;
u = griddata(x,y,xvel,X,Y) ;
v = griddata(x,y,yvel,X,Y) ;
quiver(X,Y,u,v)
5 Comments
More Answers (0)
See Also
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!