Towhid
Towhid

Reputation: 2094

Matrix element replacement Octave

I've a matrix A = [0.125680 0.543107 0.40088]

If a number in that matrix is greater or equal .5 I want to replace it with 1.

If a number is less than .5 I want to replace it with 0.

So my final matrix will be B = [0 1 0]. How will I do that without for loop?

Upvotes: 0

Views: 188

Answers (1)

Towhid
Towhid

Reputation: 2094

Get it. It simple.

B = A >= .5;

Upvotes: 1

Related Questions