Borrar filtros
Borrar filtros

Comparing two matrix per greater or equal to

1 visualización (últimos 30 días)
DP
DP el 30 de Sept. de 2018
Editada: jonas el 30 de Sept. de 2018
I have matrix A which is 1x276 and B which is 1x503305. I want to count how many values from B are greater or equal to each value of A. How would I do this?
Thanks!

Respuesta aceptada

jonas
jonas el 30 de Sept. de 2018
Editada: jonas el 30 de Sept. de 2018
arrayfun(@(x)sum(x>=B),A)

or perhaps I am reading it wrong and you need to swap A for B and vice versa

  2 comentarios
DP
DP el 30 de Sept. de 2018
I had to swap A for B, but this is correct! I learned a new function today, thanks!
jonas
jonas el 30 de Sept. de 2018
Editada: jonas el 30 de Sept. de 2018
Happy to help! :)
Arrayfun is basically a nicer way to loop over the elements of an array. Note that it is often slower than looping, so if you have very large data sets you may want to loop instead.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Productos


Versión

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by