Plotting points in 3D with mesh

84 ビュー (過去 30 日間)
AFRAZ SALIM
AFRAZ SALIM 2020 年 4 月 26 日
コメント済み: AFRAZ SALIM 2020 年 4 月 26 日
I have three vectors (X,Y,Z) of equal size. I want to plot them in 3D and interpolate the points. I use following code to plot the points but the figure that i get is not good enough. The plot that i get is also attached. Can someone explain kindly, what i am doing wrong. if more information is needed then kindly let me know.
Note that one vector represents x-coordinate while second represents y-coordinate and third one z-coordinate. If there is any better to visualize this scatter plot(interpolated) that will be also great.
plot3(first_test_vector,second_test_vector,test_label,'.'),hold on
title('1000 points selected for training data & interpolation of test data')
xlabel('x'), ylabel('y'), zlabel('Values')
legend('Sample data','Interpolated test data','Location','Best')
x = meshgrid(first_test_vector);
y = meshgrid(second_test_vector);
z = meshgrid(test_label);
mesh(x,y,z)
colorbar
title('Interpolated test data')
legend('Sample Points','Interpolated test data','Location','NorthWest')
  1 件のコメント
Rik
Rik 2020 年 4 月 26 日
Do you want to create a surface? And can you share your data or write code that will generate plausible data?

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

採用された回答

J. Alex Lee
J. Alex Lee 2020 年 4 月 26 日
編集済み: J. Alex Lee 2020 年 4 月 26 日
For just visualizing the chosen data in a surface, does this look like what you want?
clc;
close all;
clear;
N = 500;
X = rand([N,1])*2*pi;
Y = rand([N,1])*2*pi;
Z = sin(X).*cos(Y);
scatter3(X,Y,Z,'.')
T = delaunay(X,Y)
hold on
trimesh(T,X,Y,Z,"FaceAlpha",0)
For actual interpolating, look into "scatteredInterpolant"
  1 件のコメント
AFRAZ SALIM
AFRAZ SALIM 2020 年 4 月 26 日
Thanks, It worked :)

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by