Comparing vectors of different size

3 vues (au cours des 30 derniers jours)
Ben
Ben le 18 Juin 2014
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]

Réponse acceptée

Andrei Bobrov
Andrei Bobrov le 18 Juin 2014
C = A(all(bsxfun(@ge,A,B.')));

Plus de réponses (0)

Catégories

En savoir plus sur Startup and Shutdown dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by