Indexing One Column from 4D Array?

7 ビュー (過去 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 Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by