Create 3D scatter plot from an 120x160 matrix

1 Ansicht (letzte 30 Tage)
Mir Sharmin
Mir Sharmin am 7 Jul. 2017
Kommentiert: Chad Greene am 10 Jul. 2017
I have an excel file with a 120 x 160 array and I need to make a 3D scatter plot of the data. I could easily do it on Mathcad but can't get 'scatter3' to work.
Any suggestions will be appreciated!
Thanks

Antworten (2)

Chad Greene
Chad Greene am 7 Jul. 2017
Perhaps you need to columnate all your variables using (:). Like this:
[x,y,z] = peaks(150);
scatter3(x(:),y(:),z(:),10,z(:))
But if your data are gridded, why not use surf?
surf(x,y,z)
shading flat
  2 Kommentare
Mir Sharmin
Mir Sharmin am 7 Jul. 2017
scatter3 asks for a vector and doesn't take the matrix array as an input so that problem still remains.
And, unfortunately I don't think a surface plot will work for the project I am working on!
Thanks though!
Chad Greene
Chad Greene am 10 Jul. 2017
Yes, by columnating all the inputs with (:), it turns them into vectors. Did you try the example I provided with the peaks data?

Melden Sie sich an, um zu kommentieren.


Walter Roberson
Walter Roberson am 7 Jul. 2017
Bearbeitet: Walter Roberson am 7 Jul. 2017
[Y, X] = ndgrid(1:size(YourArray,1), 1:size(YourArray,2));
scatter3(X(:), Y(:), YourArray(:));
Notice that Y corresponds to rows not columns

Community Treasure Hunt

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

Start Hunting!

Translated by