简体   繁体   English

Matlab绘制三个三维矩阵

[英]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. 因此,例如,如果3D矩阵为A,则A(1,3,8)= 1表示点x = 1,y = 3和z = 8,则存在一个粒子。 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. 我想做的是绘制矩阵A。因此,我想做的就是找到矩阵A中的索引,然后在空间中绘制索引。 However, I all of the matlab functions I have come across only give the linear index, which is not what I want. 但是,我遇到的所有matlab函数都只给出线性索引,这不是我想要的。

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. 根据轴的定义,您需要翻转y轴以指向下方。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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