Correlation between a 3D matrix and a vector

8 ビュー (過去 30 日間)
Chiara Bulgarelli
Chiara Bulgarelli 2017 年 8 月 4 日
コメント済み: Brian DeCicco 2021 年 7 月 1 日
Hello everyone, I have a 3D matrix (44x44x21 - channelsxchannelsxsubjects) and a vector of 21 elements (questionnaire answers for each subject). I would like to correlate the vector with all the cells of my 3D matrix. Of course I would like that answer for subject 1 (element 1 in the vector) is correlated with 44x44x1, answer for subj 2 with 44x44x2, etc... Is someone able to help me? Many thanks in advance
Chiara
  1 件のコメント
Jan
Jan 2017 年 8 月 8 日
Some standard terms: "matrix" is a 2D array. Cells are cell arrays, which can contain non elementary data as elements. Therefore "3D matrices" do not contain "all cells".
What does "element 1 in the vector is correlated with 44x44x1" exactly mean?

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

採用された回答

Chris Perkins
Chris Perkins 2017 年 8 月 8 日
Hi Chiara,
If I understand your goal correctly, you will likely need to both re-arrange your data and expand the vector data into a 3D matrix.
To re-arrange your initial 3D matrix data, you can use the "permute" function, as shown below:
matrix = permute(matrix,[3 1 2]);
This allows you to change your 44x44x21 matrix to a 21x44x44 matrix, so the dimensions agree with the vector.
The documentation for the "permute" function is found at the following link: https://www.mathworks.com/help/matlab/ref/permute.html
Then, expand the vector to be a 21x44x44 matrix, where each element is expanded to be a 44x44 matrix of the same, repeated element.
Once the dimensions agree, you can follow the procedure to manually compute the standard Pearson coefficient, as described in the following MATLAB Answers question: https://www.mathworks.com/matlabcentral/answers/15884-correlation-for-multi-dimensional-arrays
  1 件のコメント
Brian DeCicco
Brian DeCicco 2021 年 7 月 1 日
Hey Chris! I am trying to figure out a similar problem to this one, but am unsure how to "expand my vector to be a 3-D matrix, where each element is expanded to be a 1440x721 matrix of the same, repeated element". Can you assist? Thanks!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by