Error using corrcoef. x and y must have the same number of elements....?

4 visualizzazioni (ultimi 30 giorni)
Hi everyone!
Running some fMRI stuff and we are having some trouble trying to figure out what Error using corrcoef X and Y must be have the same number of elements
for r=1:roiN
fcmap=zeros(1,numpix); %1-by-#num voxels in 3D volume
seedts=load([roiList{r},'_','residvol_ts.txt']);
for pix=1:size(fcmap,2) %1 to #num voxels in 3D volume
tmp=corrcoef(seedts,func(:,pix)); %calc correlation bewteen seed timeseries and timeseries of that voxel; tmp=2x2 symmetric corr table
pixr=tmp(1,2);
fcmap(pix)=pixr; %fill voxel with correlation coefficient
if doFisherZ
fcmap(pix)=(.5*log((1+pixr)/(1-pixr)));
else
end
end
Thanks for your help :)
  1 Commento
Mathieu NOE
Mathieu NOE il 28 Feb 2023
yeap
read the doc
% this work
A = randn(10,1);
B = randn(10,1);
R = corrcoef(A,B)
R = 2×2
1.0000 0.3131 0.3131 1.0000
% this doesn't work
A = randn(10,1);
B = randn(12,1);
R = corrcoef(A,B)
Error using corrcoef
X and Y must have the same number of elements.

Accedi per commentare.

Risposte (1)

Dinesh
Dinesh il 27 Mar 2023
Hi Ryu!
Here in this line of code
tmp=corrcoef(seedts,func(:,pix));
The time series seed array and time series voxel are not having same number of elements and without same number of elements we cannot calculate correlation coefficent. Despite how they are shaped to calculate corrcoeff we need to have same number of elements.
For more Details on how correlation coefficient is calculated and it's internal mathematics please refer the following MATLAB Documentation

Categorie

Scopri di più su Time Series in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by