필터 지우기
필터 지우기

Correlation between a 3D matrix and a vector

조회 수: 4 (최근 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 CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by