plot 3D point data

20 ビュー (過去 30 日間)
ha ha
ha ha 2018 年 11 月 23 日
コメント済み: Rik 2018 年 11 月 24 日
I have matrix A=[x y z] with 2112 point data . Please see attachment file, and figure:
2.png1.png
How can I plot the surface using that data as the illustration figure?
3.JPG

採用された回答

Rik
Rik 2018 年 11 月 23 日
編集済み: Rik 2018 年 11 月 23 日
You should be able to use the surf function. The only problem you have is interpolating the data to a normal grid that surf understands (and fill the rest with NaN).
The code below assumes your text file is stored in a 2112 by 3 array named data
x=data(:,1);
y=data(:,2);
z=data(:,3);
SamplePerDim=500;
X=linspace(min(x),max(x),SamplePerDim);
Y=linspace(min(y),max(y),SamplePerDim);
[X,Y]=ndgrid(X,Y);
F=scatteredInterpolant(x,y,z,'linear','none');
Z=F(X,Y);
figure(1),clf(1)
surf(X,Y,Z,'EdgeColor','none')
view(-160,80)
  4 件のコメント
ha ha
ha ha 2018 年 11 月 24 日
編集済み: ha ha 2018 年 11 月 24 日
I try your code. It's good. May i ask you a favor? What is the best number of "SamplePerDim" ? And, How to choose automatically the best number of "SamplePerDim" based on number of the input data? Since when I try with small value of "SamplePerDim=100". The result figure is not good
Rik
Rik 2018 年 11 月 24 日
As always, you're welcome.
I don't really know how to pick the resolution automatically. That will depend on the smoothness of your data and how much data you have. Ideally you would 2000, but that makes the plot very slow. You could use a fancy formula to estimate the best value, but because that is tricky I chose to hard code the value.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLanguage Fundamentals についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by