# How to plot a surface not sampled on a gid/mesh

3 ビュー (過去 30 日間)
Matt 2023 年 7 月 4 日
コメント済み: Matt 2023 年 7 月 4 日
Hi
Is there a function that could plot a 2D surface defined on non meshed points ?
In other words, if I have a surface defined by three one dimension vectors X,Y,Z how could I plot it ?
% generate a surface Z=f(x,y)
[X,Y] = meshgrid(linspace(0,10,40),linspace(0,10,40));
Z = sin(X) + cos(Y);
pcolor(X,Y,Z);% works great
pcolor(X(:),Y(:),Z(:)); % error
pcolor(reshape(X,4,[]),reshape(Y,4,[]),reshape(Z,4,[]));
%last one:not the result I hope for, I would like to get the same image as
%pcolor(X,Y,Z)
I know that I could create a mesh manually and interpolate on this mesh (as shown here (as shown here http://matlab.izmiran.ru/help/techdoc/visualize/chbuild7.html ) but I don't like this option as my mesh might not include the data points and give me a false sense of having a the surface sampled well enough because of the interpolation.
Thanks

サインインしてコメントする。

### 採用された回答

Chunru 2023 年 7 月 4 日
% generate a surface
X = rand([1000 1])*2*pi;
Y = rand([1000 1])*2*pi;
Z = sin(X) + cos(Y);
% trianglation
tri = delaunayn([X Y]);
trisurf(tri, X, Y, Z)
##### 1 件のコメント-1 件の古いコメントを表示-1 件の古いコメントを非表示
Matt 2023 年 7 月 4 日
Amazing !

サインインしてコメントする。

### カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

R2022a

### Community Treasure Hunt

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

Start Hunting!

Translated by