How to plot data in an irregular/non orthogonal grid?

조회 수: 50 (최근 30일)
Baptiste
Baptiste 2014년 7월 16일
답변: Baptiste 2014년 8월 6일
Hi everybody!
I am struggling for a couple a days on an issue. I have an irregular and non-orthogonal grid (see image attached) characterized by the x and y vectors giving the position of the middle of each mesh and the data(x,y). Is there a function, a way, or a magic trick that would allow me to plot my data on this non-rectangular shaped grid?
Thanks a lot,
B.

답변 (2개)

Chris Turnes
Chris Turnes 2014년 8월 5일
The mesh and surf functions can take irregularly spaced vector and matrix inputs that define the mesh. However, their inputs are the intersections of the grid lines, rather than the center of each cell of the mesh (see the documentation for mesh and the documentation for surf for more details).
As a small example, if I have an irregular mesh whose vertices are given by
>> x = [0.1, 0.4, 1.0, 2.2; ...
0.1, 0.3, 0.7, 1.5; ...
0.1, 0.2, 0.4, 0.8; ...
0.1, 0.15, 0.25, 0.45];
>> y = (0.1:0.3:1)'*ones(1,4)
and corresponding value data
>> z = [0.1; 0.5; 0.5; 0.1]*[0.1, 0.3, 0.5, 0.3];
I can use mesh to plot the data on this irregular grid
>> mesh(x, y, z)
to produce the plot
If you just want to plot the points themselves, and not a surface, you should also consider using scatter3 and stem3.

Baptiste
Baptiste 2014년 8월 6일
Hello,
Thank you for your answer, I'll find a way to recover the intersection instead and try that!
Baptiste

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by