In octave the built in function any()
will return 1 if any element of the vector is nonzero.
so for a matrix
1 0 0
0 0 0
0 1 0
it will return [1,1,0]
is there a function that will return the same but for the rows, instead of the column eg. return
1
0
1
I know I could do this with a rotation and then using the any()
function, but I'm worried it will increase the time complexity.
Is there a built in function for this?
Octave's "any" function has an optional dimension argument. Set it to 2 to work along the second dimension.
any(m, 2)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.