I was hoping that somebody might be able to help me out in creating a frequency matrix?
I normally use excel for statistical modelling but this particular problem takes hours to execute using spreadsheets.
I have created a variables called 'data' and it contains numbers ranging from 0-828.
I was hoping to create a frequency matrix of the number of times one number follows another number. Or put a different way, the number of times a number transitions to another number.
Here is a simple example with numbers ranging from 1-5.
For example, the cell in red, the number 3 is followed by 2 twice, or transitions to 2 twice.
I'd appreciate any help that is offered.
No products are associated with this question.
dcol = data(:); %need column vector form freqmatrix = accumarray( [dcol(1:end-1) + 1, dcol(2:end) + 1], 1 );
This would create a matrix up to 829 x 829. Any one position, (R,C) in it, would indicate a transition from (R-1) to (C-1). The offset of 1 is needed because you have 0 values and subscripts cannot be 0.
If the number of unique values is considerably smaller than 829, then it would be possible to make the matrix much smaller, at the expense of making it less natural to read.