Info

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

How would I go about modifying this code so that it will bin a set of 4 elements?

조회 수: 4 (최근 30일)
Ellie
Ellie 2015년 7월 27일
마감: Walter Roberson 2015년 7월 27일
I have this following code where the is a pair of [ic(k), ic(k+1)]. Is there any way to modify it so that you can bin [[ic(k), ic(k+1), ic(k+2), ic(k+3)] instead? I have been playing with it but I keep getting errors, or a 4D matrix. Not what I want. Thanks in advance.
d = [3 3 4 4 4 5 6 5 5 4];
[c, ~, ic] = unique(d);
N = numel(c);
p = zeros(N, N);
for k = 1:(numel(d) - 1)
p(ic(k), ic(k + 1)) = p(ic(k), ic(k + 1)) + 1;
end
p = bsxfun(@rdivide, p, sum(p, 2));

답변 (0개)

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by