Generate a Grid from Nodes Coordinates
조회 수: 6 (최근 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
댓글 수: 0
답변 (1개)
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);
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Vector Fields에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!