Find the number of rows and columns of non-zero number from certain row.

조회 수: 1 (최근 30일)
fyza affandi
fyza affandi 2018년 11월 28일
댓글: fyza affandi 2018년 11월 28일
Given a matrix named Matr below;
Matr =
0 0
0 0
1 0
0 0
2 0
0 1
1 1
How can I find the number of column and row form beginning of row to only row 6?
The result should be
[3 1
5 1
6 2]

채택된 답변

YT
YT 2018년 11월 28일
You can do something like this
[r, c] = find(Matr(1:6,:));
res = [r c]
%res =
%
% 3 1
% 5 1
% 6 2

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by