Comparing vectors of different size

조회 수: 3 (최근 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 CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by