Plotting 3D mesh from 3 data columns

21 次查看(过去 30 天)
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 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