Plotting 3D mesh from 3 data columns

17 ビュー (過去 30 日間)
Bendix
Bendix 2022 年 11 月 23 日
コメント済み: Bendix 2022 年 11 月 28 日
I have an excel file with 3 colums (X,Y and Z coordiantes) which i would like to plot as a surface (heat map) in 3D. Preferably I would like my x and y axis to be shown with the following lengths: x = 0 - 11.5 and y = 0 - 7.6

採用された回答

Sakshay
Sakshay 2022 年 11 月 28 日
Hi Bendix,
As per my understanding, you are trying to create a 3D surface plot from X,Y,Z points.
You need to interpolate the points to plot them as a surface. The points can be interpolated using the "griddata()" function. The following example will illustrates how to do that:
% Read the data points as a matrix
T = readmatrix('3DPlot.xlsx');
% Create a meshgrid for plotting
[xq,yq] = meshgrid(0:.2:11.5, 0:.2:7.6);
% Interpolate the points using griddata function
vq = griddata(t(:, 1), t(:, 2), t(:, 3),xq,yq);
% Plot the surface
mesh(xq,yq,vq);
hold on;
% Plot the points
plot3(t(:, 1), t(:, 2), t(:, 3),'o');
% Set the X and Y Limits
xlim([0 11.5]);
ylim([0 7.6]);
Please refer to the following documentation for more information on "griddata()" function:
  1 件のコメント
Bendix
Bendix 2022 年 11 月 28 日
Perfect, thank you very much and thanks for the explanations of the lines! Just a small correction, the first varable should be lower case t and it works like a charm

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by