Indexing One Column from 4D Array?

8 views (last 30 days)
hlee7355
hlee7355 on 22 Mar 2023
Commented: Luca Ferro on 22 Mar 2023
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 Comment
Luca Ferro
Luca Ferro on 22 Mar 2023
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?

Sign in to comment.

Answers (1)

Cris LaPierre
Cris LaPierre on 22 Mar 2023
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,:));

Categories

Find more on Matrices and Arrays in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!