moondog
moondog

Reputation: 1577

octave matrix: replace 0's with 1's and replace 1's with 0's

I have a matrix of 0's and 1's, say:

0 1 0 0
0 0 1 0
1 0 0 0

I want to generate another matrix that replaces 0's with 1's and 1's with 0's:

1 0 1 1
1 1 0 1
0 1 1 1

Anyone know how to do this in Octave?

Upvotes: 0

Views: 394

Answers (1)

Oliver Charlesworth
Oliver Charlesworth

Reputation: 272497

b = 1 - a;

Upvotes: 5

Related Questions