calculate weight of each 2D data point
조회 수: 8 (최근 30일)
이전 댓글 표시
a data set consists of x and y, if I want to find out the associated weights for each point. What can I do?
댓글 수: 0
채택된 답변
Walter Roberson
2011년 3월 10일
Please expand on your question.
Are you trying to find out how many of the points fall in to each square of a grid? If so, then you can use accumarray for that:
xgrid = 1 + floor(Nx * (x - min(x)) ./ (max(x) - min(x)));
ygrid = 1 + floor(Ny * (y - min(y)) ./ (max(y) - min(y)));
weights = accumarray([xgrid(:), ygrid(:)], 1);
This will produce an Nx by Ny grid of counts.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Clocks and Timers에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!