iomartin
iomartin

Reputation: 3199

Replace all occurrences of a value in a column

I need to replace several occurences of a number (5) in the first column of my matrix for -1. How can I do it?

Upvotes: 1

Views: 2580

Answers (1)

R. Schifini
R. Schifini

Reputation: 9313

Try this:

A(A(:,1)==5,1) = -1

Hope this helps.

Upvotes: 10

Related Questions