Adding to the first value in a matrix based on the second value in that row.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Toby
am 7 Jan. 2020
Beantwortet: Alex Mcaulley
am 7 Jan. 2020
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.
0 Kommentare
Akzeptierte Antwort
Alex Mcaulley
am 7 Jan. 2020
Being A your matrix:
A(A(:,2) == 11 | A(:,2) == 12,1) = A(A(:,2) == 11 | A(:,2) == 12,1) + 1
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Get Started with MATLAB finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!