필터 지우기
필터 지우기

Comparing two matrix per greater or equal to

조회 수: 1 (최근 30일)
DP
DP 2018년 9월 30일
편집: jonas 2018년 9월 30일
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!

채택된 답변

jonas
jonas 2018년 9월 30일
편집: jonas 2018년 9월 30일
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
DP
DP 2018년 9월 30일
I had to swap A for B, but this is correct! I learned a new function today, thanks!
jonas
jonas 2018년 9월 30일
편집: jonas 2018년 9월 30일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품


릴리스

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by