필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

How to code this?

조회 수: 1 (최근 30일)
Lucas
Lucas 2014년 1월 25일
마감: MATLAB Answer Bot 2021년 8월 20일
Hi all,
Currently I have matrix which rows I want to divide into bins. However, the edges of these bins should be different for every row. Example:
Data= [ 1 1.5 2 3 4; 1. 2 4 5 6;]
edges= [1 2 3; 3 4 5]
I want to use the command [counts, bins] = histc(). I can code this using a for-loop, but is there a possibility to this in a vectorized way? That the output is a 2x5 "counts" and 2x5 "bins" matrix, in which the Data rows have been split according to different edges criteria?
Thanks in advance!
Lucas

답변 (1개)

Amit
Amit 2014년 1월 25일
histc supports matrixes. So you dont hove to use for loop. http://www.mathworks.com/help/matlab/ref/histc.html
  댓글 수: 2
Lucas
Lucas 2014년 1월 25일
Hi Amit, Thanks for your response, but that doesnt answer my question. The question is about how to use multiple 'edges' vectors, so every row of a matrix is binned differently. "Histc" doesnt support that by default; you can input a matrix for edges, but histc sees it reads it as one binning criterium, rather than a new binning criterium for each row.
Lucas
Amit
Amit 2014년 1월 25일
I see. I think looping would be the option. However, if it only 2 rows and 2 edges, you can just use histc twice instead of for .. end

이 질문은 마감되었습니다.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by