Adding to the first value in a matrix based on the second value in that row.

1 回表示 (過去 30 日間)
Toby
Toby 2020 年 1 月 7 日
回答済み: Alex Mcaulley 2020 年 1 月 7 日
I have a matrix which has 4 columns and a number of rows. I simply want to add 1 to the value in the first column of a row if the second column has the value of 11 or 12 in it.

採用された回答

Alex Mcaulley
Alex Mcaulley 2020 年 1 月 7 日
Being A your matrix:
A(A(:,2) == 11 | A(:,2) == 12,1) = A(A(:,2) == 11 | A(:,2) == 12,1) + 1

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by