Filter löschen
Filter löschen

How to build a 3D chart from a 2D table

4 Ansichten (letzte 30 Tage)
Hugo
Hugo am 9 Aug. 2022
Bearbeitet: Cris LaPierre am 9 Aug. 2022
Hi,
I have a 10*20 table, with each cell having a numeric value. I would like to build a 3D chart, having x as the dimension 10 of my table, x as the dimension 20 and z as the numeric value of each cell. How can I do it, assuming that I have the data in an excel file?
I thank you in advance,
Best regards,

Antworten (1)

Cris LaPierre
Cris LaPierre am 9 Aug. 2022
Bearbeitet: Cris LaPierre am 9 Aug. 2022
What type of 3d chart do you want to create?
For a surface, you could use the following syntax (Z needs to be a matrix). Just note that the rows correspond to y and the columns to x, so you need to transpose the matrix to get what you want.
surf(Z) creates a surface plot and uses the column and row indices of the elements in Z as the x- and y-coordinates.
Z = rand(10,20);
surf(Z') %
xlabel('X')
ylabel('Y')
zlabel('Z')
This syntax is not universal across all 3D plotting functions. When it isn't, you can create X and Y vectors first.
x = 1:size(Z,1);
y = 1:size(Z,2);
[X,Y] = meshgrid(x,y);
scatter3(X,Y,Z')

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Produkte


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by