is anyone know, how to know the matrix coordinate..?

2 次查看(过去 30 天)
is anyone know, how to know the matrix coordinate..?
a = [1 1 0; 0 0 0; 0 0 1;];
1 have coordinate on, (1,1) (1,2) and (3,3)
how to know the matrix coordinate..?

采纳的回答

Wayne King
Wayne King 2013-12-1
编辑:Wayne King 2013-12-1
a = [1 1 0; 0 0 0; 0 0 1;];
idx = find(a==1); % linear coordinates
[I,J] = ind2sub(size(a),idx);
The I,J pairs are the "matrix coordinates"

更多回答(2 个)

Azzi Abdelmalek
Azzi Abdelmalek 2013-12-1
In your case, you have only 1 and 0
a = [1 1 0; 0 0 0; 0 0 1;];
[ii,jj]=find(a)

nu
nu 2013-12-1
very thank you @wayne king and @azzi abdelmalek for your answer, that was very help me:)

类别

Help CenterFile Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by