简体   繁体   English

在八度中,是否有像any()的函数,但是用于行而不是列?

[英]In Octave is there function like any() but for rows instead of columns?

In octave the built in function any() will return 1 if any element of the vector is nonzero. 在八度中,如果向量的任何元素都不为零,则内置函数any()将返回1。

so for a matrix 所以对于矩阵

1 0 0 

0 0 0

0 1 0

it will return [1,1,0] 它将返回[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. 我知道我可以先旋转然后再使用any()函数,但是我担心这会增加时间复杂度。

Is there a built in function for this? 是否有内置功能?

Octave's "any" function has an optional dimension argument. 八度的“ any”函数具有可选的Dimension参数。 Set it to 2 to work along the second dimension. 将其设置为2即可沿第二维工作。

any(m, 2)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM