find index of a element present in matrix

2 ビュー (過去 30 日間)
anakhi hazarika
anakhi hazarika 2019 年 9 月 20 日
回答済み: madhan ravi 2019 年 9 月 20 日
Hi...
I have a matrix A= [0 0 1 1; 1 0 0 1; 0 0 0 1]. I want to find the index of the first 1 of a row and want to save in a column matrix Z. In this case Z must be: Z=[ 3; 1; 4]. I am using this command Z = find(A(1,:), 1, 'first') but unable to do for second and third row. Kindly provide necessary codes for solving this.
Thank you.

採用された回答

madhan ravi
madhan ravi 2019 年 9 月 20 日
[~,Z]=max(A,[],2)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by