Error using corrcoef. x and y must have the same number of elements....?
조회 수: 4 (최근 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에서 Time Series에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!