How can I split a large matrix into many cells (with multiple values)

Hi all,
I'm currently using a data set for football teams in the 2016/17 season.
There is a matrix X which contains data for team i facing team j.
I have a 552 x 92 matrix where each:
Row 1 = # Matches played,
Row 2 = # Wins,
Row 3 = # Losses,
Row 4 = # Draws,
Row 5 = Goal differential,
Row 6 = # Games played at home,
This then begins again, so row 7 would be another team's data.
What I aim to do is create a matrix M which for each cell contains the vector of all the above data for each team occurrence - so that I can continue with this and go on to logistic regression of the variables.
I've seen the mat2cell and accumarray functions for this but am unsure which to continue with as each appear to have errors with this.
Any advise would be appreciated,
Cheers,
H

 採用された回答

Walter Roberson
Walter Roberson 2017 年 12 月 22 日

0 投票

data = permute( reshape(TheArray, 7, [], size(TheMatrix,2)), [2 3 1]);
Now data(J,K,1) is matches played between J and K, data(J,K,2) is wins, data(J,K,3) is losses, and so on.

2 件のコメント

Harry O'Connell
Harry O'Connell 2017 年 12 月 27 日
Cheers for this, it worked with the above formula but with 6 instead of 7,
With what I have with this array, would you know how to go on to perform linear regression on these? with each variable being (:,:,1), (:,:,2)...(:,:,6) ? I have tried but they are normally simple n x 1 vectors in the examples I have seen and cannot find any other.
Walter Roberson
Walter Roberson 2017 年 12 月 27 日
What would you be regressing against what?
Linear regression allows a 2D matrix of x and a vector of y, but it is not clear to me that would help you.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeDescriptive Statistics and Insights についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by