2

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 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

1 Comment

I think you meant plot3.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.