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

조회 수: 2 (최근 30일)
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 CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by