Error using corrcoef. x and y must have the same number of elements....?
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
Mathieu NOE
2023-2-28
yeap
read the doc
% this work
A = randn(10,1);
B = randn(10,1);
R = corrcoef(A,B)
% this doesn't work
A = randn(10,1);
B = randn(12,1);
R = corrcoef(A,B)
回答(1 个)
Dinesh
2023-3-27
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
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 3-D Volumetric Image Processing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!