Indexing One Column from 4D Array?

조회 수: 3 (최근 30일)
hlee7355
hlee7355 2023년 3월 22일
댓글: Luca Ferro 2023년 3월 22일
Hi,
I'm trying to create a correlation coefficient between two variables of 716 elements. One of the variables (func) is a 84 x 84 x 52 x 716 array and I want to take the 716 elements from it. The other variable (seedts) is already formatted as 716x1.
When I run this code, I get an error using corrcoef that X and Y must have the same number of elements.
fcmap=zeros(1,84);
fcmap=fcmap.';
for pix = 1:size(fcmap,2)
tmp=corrcoef(seedts,func)
pixr=tmp(1:2);
fcmap2(pix)=pixr
if doFisherZ
fcmap(pix)=(.5*long((1+pixr)/(1-pixr)));
else
end
end
Any suggestions for how to do this? Thanks!
  댓글 수: 1
Luca Ferro
Luca Ferro 2023년 3월 22일
i don't quite undersand the request.
''I want to take the 716 elements from it'' confuses me. Since you have a 4d matrix every single combination of values will have 716 elements.
This works, but it consider the 716 elements of only one combination.
corrcoef(seedts,func(1,1,1,1:end))
meaning that this one works as well:
corrcoef(seedts,func(1,1,2,1:end))
and so all the combination in the dimensions 84x84x52.
Do you want to loop through all of them or are you interested in one specific?

댓글을 달려면 로그인하십시오.

답변 (1개)

Cris LaPierre
Cris LaPierre 2023년 3월 22일
one of the variables has 262708992 elements while the other has 716. You haven't specified which row, column, and page you want to extract the 'column' of 716 values from, but it might look something like this.
tmp=corrcoef(seedts,func(pix,pix,1,:));

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by