Create 3D scatter plot from an 120x160 matrix

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

답변 (2개)

Chad Greene
Chad Greene 2017년 7월 7일

0 개 추천

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

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!
Yes, by columnating all the inputs with (:), it turns them into vectors. Did you try the example I provided with the peaks data?

댓글을 달려면 로그인하십시오.

Walter Roberson
Walter Roberson 2017년 7월 7일
편집: Walter Roberson 2017년 7월 7일

0 개 추천

[Y, X] = ndgrid(1:size(YourArray,1), 1:size(YourArray,2));
scatter3(X(:), Y(:), YourArray(:));
Notice that Y corresponds to rows not columns

카테고리

도움말 센터File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

질문:

2017년 7월 7일

댓글:

2017년 7월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by