필터 지우기
필터 지우기

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 (최근 30일)
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]

채택된 답변

Blackadder
Blackadder 2016년 10월 8일
편집: Blackadder 2016년 10월 9일
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))

추가 답변 (1개)

Andrei Bobrov
Andrei Bobrov 2016년 10월 9일
편집: Andrei Bobrov 2016년 10월 9일
sum(x(:) > k(:)') % in r2016b

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by