Comparing vectors of different size

1 回表示 (過去 30 日間)
Ben
Ben 2014 年 6 月 18 日
回答済み: Andrei Bobrov 2014 年 6 月 18 日
How do I compare two vectors of different size? I want to compare them using the "greater than or equal to operator" or "less than operator". Here's what I'm trying to vectorize:
A = [1 2 3 4 5]; B = [1 2 3]; for i = 1:length(B) C = find(A >= B(i)); end % C = [3 4 5]

採用された回答

Andrei Bobrov
Andrei Bobrov 2014 年 6 月 18 日
C = A(all(bsxfun(@ge,A,B.')));

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by