Error: Index exceeds matrix dimensions
이전 댓글 표시
Hi,
I am trying to open a .mat correlation file (I'm a neuroimaging researcher), which contains 160x160 functional connectivity matrices. I am trying to load it into my script so that I can pick 11 regions of interest set as variable 'd', from the 160x160 matrix. However, when I try to run my code, it comes back as error 'index exceeds matrix dimensions'. Any ideas on how to solve this would be greatly appreciated. Thanks!
%Begin by defining variables%
ROICorrelation = ('ROICorrelation_0010028.mat'); % Define path
%ROI1 = % VMPFC
%ROI4 = % mPFC
%ROI6 = % vmPFC
%ROI7 = % vmPFC
%ROI11 = % vmPFC
%ROI14 = % ACC
%ROI17 = % sup-frontal
%ROI73 = %post-cingulate
%ROI85 = %precuneus
%ROI117 = %angular gyrus
%ROI136 = % occipital
d = [1,4,6,7,11,14,17,73,85,117,136]; % Define Default Mode ROIs as 'd'
x = ROICorrelation(d,d); % Run correlation analyses (i.e. ROI x ROI pairs) for DMN ROIs in a new matrix 'x'
_____________________________________________________________
Index exceeds matrix dimensions.
Error in subj0010028 (line 26)
x = ROICorrelation(d,d); % Run correlation analyses (i.e. ROI x ROI pairs) for DMN ROIs in a new matrix 'x'
답변 (1개)
Walter Roberson
2018년 2월 23일
ROICorrelation = ('ROICorrelation_0010028.mat')
defines ROICorrelation to be a character vector that happens to contain 26 characters.
x = ROICorrelation(d,d)
attempts to access a variety of positions in that character vector, including (1,1), (1,4), ... (1,136), (4,1), (4,4), ... (4, 136), right up to (136,117) and (136,136). Those positions mostly do not exist in the character vector.
Perhaps you wanted to load() some data from the .mat file -- but even if so then it seems odd that you would happen to want that wide a combination of positions. And if ROICorrelation is expected to be data loaded from the file named earlier, then that does not agree with "Run correlation analyses", which sounds like ROICorrelation is intended to be a function.
댓글 수: 7
Amritha Harikumar
2018년 2월 23일
Walter Roberson
2018년 2월 23일
You do not have a 160 x 160 matrix at this point: you have a character vector (length 26). You probably need to load() something from the file name designated by the character vector. That would probably give you the 160 x 160 matrix you want.
After that, it is not clear what is necessary to select "regions of interest". Possibly what you have already is what you need. Possibly what you need is ROICorrelation(d,:) or ROICorrelation(:,d) . What size of output are you expecting?
Amritha Harikumar
2018년 2월 23일
편집: Amritha Harikumar
2018년 2월 23일
Walter Roberson
2018년 2월 23일
ROICorrelation_file = 'ROICorrelation_0010028.mat';
datastruct = load(ROICorrelation_file);
fn = fieldnames(datastruct);
ROICorrelation = datastruct.(fn{1}); %load first variable from .mat whatever the name of it is
d = [1,4,6,7,11,14,17,73,85,117,136]; % Define Default Mode ROIs as 'd'
x = ROICorrelation(d,d); % Run correlation analyses (i.e. ROI x ROI pairs) for DMN ROIs in a new matrix 'x'
Amritha Harikumar
2018년 2월 23일
Walter Roberson
2018년 2월 23일
Unless the matrices were created by a third party code that violated the rules about valid variable names (uncommon but not unheard of), the single most likely possibility is that your .mat files are not binary MATLAB files and are instead badly named text files.
Amritha Harikumar
2018년 2월 23일
카테고리
도움말 센터 및 File Exchange에서 Neuroimaging에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!