Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在 Matlab 中有两个数组说 A = [1 4 89 2 67 247 2] B = [0 1 1 1 0 0 1]
我想要一个数组 C,它包含数组 A 中的元素,如果 B 在相应索引处有 1。在这种情况下,C = [4 89 2 2]。
这该怎么做?
使用逻辑索引:
>> C = A(logical(B)) C = 4 89 2 2