Plot 3D data from excel file (2024)

20 次查看(过去 30 天)

显示 更早的评论

vipul vibhanshu about 12 hours 前

  • 链接

    此问题的直接链接

    https://ww2.mathworks.cn/matlabcentral/answers/2132126-plot-3d-data-from-excel-file

  • 链接

    此问题的直接链接

    https://ww2.mathworks.cn/matlabcentral/answers/2132126-plot-3d-data-from-excel-file

回答: Star Strider about 10 hours 前

  • Copy of data.xlsx

I am unable to plot the surface plot for the data from the excel sheet

0 个评论

显示 -2更早的评论隐藏 -2更早的评论

请先登录,再进行评论。

请先登录,再回答此问题。

回答(3 个)

Muskan about 11 hours 前

  • 链接

    此回答的直接链接

    https://ww2.mathworks.cn/matlabcentral/answers/2132126-plot-3d-data-from-excel-file#answer_1477351

  • 链接

    此回答的直接链接

    https://ww2.mathworks.cn/matlabcentral/answers/2132126-plot-3d-data-from-excel-file#answer_1477351

You can use the "surf" function in MATLAB to plot the surface plot. Please follow the following steps:

1) Prepare Your Excel File:

Ensure your Excel file is organized such that it represents a grid of Z values. The first row and first column can represent the X and Y coordinates, respectively.

2) Read Data from Excel File:

Use the readmatrix function to read the data from the Excel file into MATLAB.

3) Extract X, Y, and Z Data:

Extract the X, Y, and Z data from the matrix.

4) Plot the Surface:

Use the "surf" function to create a surface plot.

Refer to the following documentation of "surf" for a better understanding:

0 个评论

显示 -2更早的评论隐藏 -2更早的评论

请先登录,再进行评论。

Pavan Sahith about 11 hours 前

  • 链接

    此回答的直接链接

    https://ww2.mathworks.cn/matlabcentral/answers/2132126-plot-3d-data-from-excel-file#answer_1477376

  • 链接

    此回答的直接链接

    https://ww2.mathworks.cn/matlabcentral/answers/2132126-plot-3d-data-from-excel-file#answer_1477376

Hello Vipul,

I see that you're trying to generate a surface plot using data from your Excel file.

To achieve that in MATLAB , you can refer to the following sample code which will help,

% Load the data from the Excel sheet

data = readtable('data.xlsx');

% Extract the columns

Primary = data.Primary;

Auger = data.Auger;

Yield = data.Yield;

% Remove rows with NaN values in Yield

validIdx = ~isnan(Yield);

Primary = Primary(validIdx);

Auger = Auger(validIdx);

Yield = Yield(validIdx);

% Create a grid of unique Primary and Auger values

[PrimaryGrid, AugerGrid] = meshgrid(unique(Primary), unique(Auger));

% Interpolate Yield values onto the grid

YieldGrid = griddata(Primary, Auger, Yield, PrimaryGrid, AugerGrid);

% Create the surface plot

figure;

surf(PrimaryGrid, AugerGrid, YieldGrid);

xlabel('Primary');

ylabel('Auger');

zlabel('Yield');

title('Surface Plot of Yield');

colorbar; % Add a color bar to indicate the scale of Yield

This approach uses griddata to interpolate the Yield values onto the grid, ensuring that the surface plot is properly populated with data points.

The interpolation step using griddata is essential because it helps in creating a continuous surface from discrete data points.

Consider referring to the following MathWorks documentation to get a better understanding

Hope this helps you in moving ahead

0 个评论

显示 -2更早的评论隐藏 -2更早的评论

请先登录,再进行评论。

Star Strider about 10 hours 前

  • 链接

    此回答的直接链接

    https://ww2.mathworks.cn/matlabcentral/answers/2132126-plot-3d-data-from-excel-file#answer_1477426

  • Copy of data.xlsx

Use the scatteredInterpolant function to create the surface.

Using the provided data —

T1 = readtable('Copy of data.xlsx')

T1 = 21x3 table

Primary Auger Yield _______ _____ _____ 2000 950 NaN 2500 530 27.5 2000 530 34.81 2000 530 18.9 2700 590 21.7 2800 580 17.5 4000 750 18.4 4000 950 25.7 4000 950 24 4100 950 NaN 2500 700 23.2 4000 950 NaN 4000 950 NaN 4000 950 23.8 4300 900 27.5 2500 400 25.5

VN = T1.Properties.VariableNames;

x = T1.Primary;

y = T1.Auger;

z = T1.Yield;

figure

stem3(x, y, z)

hold on

scatter3(x, y, z, 50, z, 'filled')

hold off

colormap(turbo)

colorbar

xlabel(VN{1})

ylabel(VN{2})

zlabel(VN{3})

axis('padded')

title('Stem - Scatter Plot Of Original Data')

Plot 3D data from excel file (5)

xv = linspace(min(x), max(x), 50);

yv = linspace(min(y), max(y), 50);

[X,Y] = ndgrid(xv, yv);

F = scatteredInterpolant(x, y, z);

Warning: Duplicate data points have been detected and removed - corresponding values have been averaged.

Z = F(X,Y);

figure

surfc(X, Y, Z)

colormap(turbo)

colorbar

xlabel(VN{1})

ylabel(VN{2})

zlabel(VN{3})

% axis('padded')

title('Surface Plot Of Original Data')

Plot 3D data from excel file (6)

Interpolatting the missing data yields this result —

T1 = fillmissing(T1, 'linear')

T1 = 21x3 table

Primary Auger Yield _______ _____ _____ 2000 950 20.19 2500 530 27.5 2000 530 34.81 2000 530 18.9 2700 590 21.7 2800 580 17.5 4000 750 18.4 4000 950 25.7 4000 950 24 4100 950 23.6 2500 700 23.2 4000 950 23.4 4000 950 23.6 4000 950 23.8 4300 900 27.5 2500 400 25.5

VN = T1.Properties.VariableNames;

x = T1.Primary;

y = T1.Auger;

z = T1.Yield;

figure

stem3(x, y, z)

hold on

scatter3(x, y, z, 50, z, 'filled')

hold off

colormap(turbo)

colorbar

xlabel(VN{1})

ylabel(VN{2})

zlabel(VN{3})

axis('padded')

title('Stem - Scatter Plot Of Interpolated (‘Filled’) Data')

Plot 3D data from excel file (7)

xv = linspace(min(x), max(x), 50);

yv = linspace(min(y), max(y), 50);

[X,Y] = ndgrid(xv, yv);

F = scatteredInterpolant(x, y, z);

Warning: Duplicate data points have been detected and removed - corresponding values have been averaged.

Z = F(X,Y);

figure

surfc(X, Y, Z)

colormap(turbo)

colorbar

xlabel(VN{1})

ylabel(VN{2})

zlabel(VN{3})

% axis('padded')

title('Surface Plot Of Interpolated (‘Filled’) Data')

Plot 3D data from excel file (8)

I am assuming that you want them plotted in this order. If not, change the original assignments for ‘x’, ‘y’ and ‘z’, in both sections (‘Original’ and ‘Interpoalted’). My code should adapt automatically to those changes.

.

0 个评论

显示 -2更早的评论隐藏 -2更早的评论

请先登录,再进行评论。

请先登录,再回答此问题。

另请参阅

标签

  • plotting
  • 3d plots
  • surface plot

产品

  • MATLAB

版本

R2024a

Community Treasure Hunt

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

Start Hunting!

发生错误

由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。


Translated by Plot 3D data from excel file (9)

Plot 3D data from excel file (10)

选择网站

选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:

您也可以从以下列表中选择网站:

美洲

欧洲

亚太

联系您当地的办事处

Plot 3D data from excel file (2024)
Top Articles
Latest Posts
Article information

Author: Duncan Muller

Last Updated:

Views: 5702

Rating: 4.9 / 5 (79 voted)

Reviews: 86% of readers found this page helpful

Author information

Name: Duncan Muller

Birthday: 1997-01-13

Address: Apt. 505 914 Phillip Crossroad, O'Konborough, NV 62411

Phone: +8555305800947

Job: Construction Agent

Hobby: Shopping, Table tennis, Snowboarding, Rafting, Motor sports, Homebrewing, Taxidermy

Introduction: My name is Duncan Muller, I am a enchanting, good, gentle, modern, tasty, nice, elegant person who loves writing and wants to share my knowledge and understanding with you.