Filter löschen
Filter löschen

Correlation between a 3D matrix and a vector

1 Ansicht (letzte 30 Tage)
Chiara Bulgarelli
Chiara Bulgarelli am 4 Aug. 2017
Kommentiert: Brian DeCicco am 1 Jul. 2021
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 Kommentar
Jan
Jan am 8 Aug. 2017
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?

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Chris Perkins
Chris Perkins am 8 Aug. 2017
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 Kommentar
Brian DeCicco
Brian DeCicco am 1 Jul. 2021
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!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by