Creating a grid from a 2D scatter plot of vectors
40 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Roisin Coveney
il 22 Giu 2021
Commentato: Roisin Coveney
il 22 Giu 2021
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 Commenti
Risposta accettata
KSSV
il 22 Giu 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 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!