Is it possible to convert octave type BoolMatrix to Matrix? Calling norm(BoolMatrix) fails

StackOverflow https://stackoverflow.com/questions/13129021

  •  15-07-2021
  •  | 
  •  

I'm trying to normalize P, a bool matrix of size n x m by doing P = P/norm(P).

The call to norm() fails with:

xnorm: wrong type argument `bool matrix'. It seems that octave has a specific type BoolMatrix which P is an instance of; is it possible to cast it to a Matrix, or otherwise work around the problem?

有帮助吗?

解决方案

You can 'cast' the matrix by multiplying it by the identity:

P = eye(size(P))*P
P = P/norm(P)

I couldn't find any way to cast a boolean matrix to another kind, and it looks like casting matrices in general is tricky.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top