Is it possible to convert octave type BoolMatrix to Matrix? Calling norm(BoolMatrix) fails
Question
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?
Solution
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.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow