小编rmv*_*rmv的帖子

Octave/Matlab:vectorising'=='运算符?

我可以使用'=='运算符和'find()'函数在向量'data'中查找值的位置,即45的位置:

data = [ 71 65 23 45 34 12 21 34 52 ];
value = 45;

find (data == value)
ans =  4
Run Code Online (Sandbox Code Playgroud)

有没有办法在不使用循环的情况下为几个值做同样的事情,即我想在一次调用中得到[4 5 7]:

values = [ 45 34 21 ];
find (data == values)
error: mx_el_eq: nonconformant arguments (op1 is 1x9, op2 is 1x3)
error: evaluating argument list element number 1
error: evaluating argument list element number 1
Run Code Online (Sandbox Code Playgroud)

matlab operators vectorization find octave

8
推荐指数
1
解决办法
2084
查看次数

标签 统计

find ×1

matlab ×1

octave ×1

operators ×1

vectorization ×1