Matlab 如何显示矩阵中的坐标?

Matlab 如何显示矩阵中的坐标?,matlab,matrix,Matlab,Matrix,我想用X和Y来显示矩阵的坐标 if matrix = [ 0 0 5 0; 0 0 1 0; 0 0 0 1; 0 0 0 0] 比如说,我想要5的坐标……我怎么能写出一个表示5=1x和3y的代码呢 我不想在矩阵中显示元素,只想显示该元素的坐标。使用find [y x] = find( matrix ~= 0 ); % gives you the x y coordinates of all non-zero elements 注意y和x的顺序,因为Matlab使用行-列进行索引。或者如果

我想用X和Y来显示矩阵的坐标

if matrix = [ 0 0 5 0; 0 0 1 0; 0 0 0 1; 0 0 0 0]
比如说,我想要5的坐标……我怎么能写出一个表示
5=1x和3y
的代码呢

我不想在矩阵中显示元素,只想显示该元素的坐标。

使用
find

[y x] = find( matrix ~= 0 ); % gives you the x y coordinates of all non-zero elements 

注意
y
x
的顺序,因为Matlab使用行-列进行索引。

或者如果您只想找到五个,当然是
find(matrix==5)