简体   繁体   中英

Matlab Plotting A Three DImensional Matrix

I have a three dimensional matrix, in which are randomly distributed ones. A one represents a particle at that position. So, for instance, if the 3D matrix is A, then A(1,3,8)=1 means that the point x=1, y=3, and z=8, there is a particle. What I would like to do is plot the matrix A. So, what I figured I would do is find the indices of the ones in the matrix A, and then plot the indices in space. However, I all of the matlab functions I have come across only give the linear index, which is not what I want.

How can I accomplish this?

As far as I know, plotting it directly is not possible. Convert it to indices:

[y,x,z]=ind2sub(size(X),find(X))
plot3(x,y,z,'o')

Depending on the definition of axis, you need to flip the y axis to point downwards.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM