Borrar filtros
Borrar filtros

i have a vector x=[1 2 3 1 4 4.3 3 3.7 4.8],consider a variable k=4:0.2:5, how many values of x are greater than k(i.e) so the output will show [2 1 1 0 0]

2 visualizaciones (últimos 30 días)
i have a vector x=[1 2 3 1 4 4.3 3 3.7 4.8], consider a variable k=4:0.2:5, I need to find how many values of x are greater than k(i.e)
so the output will show [2 1 1 0 0]

Respuesta aceptada

Blackadder
Blackadder el 8 de Oct. de 2016
Editada: Blackadder el 9 de Oct. de 2016
First, with x and k as defined by you, the output should be
[2 2 1 1 0 0]
You can compute this by
x = [1 2 3 1 4 4.3 3 3.7 4.8];
k = 4:0.2:5;
sum(bsxfun(@gt,x',k))

Más respuestas (1)

Andrei Bobrov
Andrei Bobrov el 9 de Oct. de 2016
Editada: Andrei Bobrov el 9 de Oct. de 2016
sum(x(:) > k(:)') % in r2016b

Categorías

Más información sobre Multidimensional Arrays en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by