2
votes

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?

1

1 Answers

3
votes

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.