how to create a surf plot for {x, y, z} where z is also a vector, thanks all!

조회 수: 3 (최근 30일)
Hi all, my problems are This is a simple mesh with four points 1,2 3 and 4, whose coordination are (x1, y1),...,(x4, y4), now i have the coordination values at X axis and y
node_x=[x1, x2, x3, x4]; node_y=[y1, y2, y3, y4]; and the z value for each point as
node_z=[z1, z2, z3, z4];
4--------------------3
| |
| |
| |
| |
| |
| |
| |
| |
| |
1--------------------2
I have to get a surf plot of these mesh points, however, my z values are not a matrix but a vector, do any body know how to create this surf plot?
For this matlab code as
clear clc node_x=[0, 20, 20, 0]; node_y=[0, 0, 20, 20]; node_z=[0.4, 0.4, 0.3, 0.3]
Thanks a lot.

채택된 답변

Sean de Wolski
Sean de Wolski 2012년 2월 13일
You need to have points as 2d matrices in order to use mesh or surf. Look into meshgrid and interp2 to get your points onto a grid. For simples cases like this, you might prefer to just call patch directly.
node_x=[0, 20 20, 0];
node_y=[0, 0 20, 20];
node_z=[0.4, 0.4 0.3, 0.3];
patch(node_x,node_y,node_z,node_z)

추가 답변 (0개)

카테고리

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