Index exceeds matrix dimensions.
1 次查看(过去 30 天)
显示 更早的评论
I have a set of data: (120,120,60), when reshaped, it gives (120,120,6,10).i.e a group of six data set occurring 10 times. I'm interested in subtracting the last 3 of the six group from the first 3 and again from the next 3 in another group of the next 6 group. My code is as follows:
Freq = [-30 -40 -50 50 40 30]; % offset frequency range
However, I divided the data into a set of 3(s), so that it can be easy to manipulate.
Freq1 = [-30 -40 -50];
ANNe = reshape(ANN,[size(ANN,1), size(ANN,2), length(Freq1),
size(ANN,3)./length(Freq1)]); % reshaping command for 60 images to 6 set of 10 compartment.
for i = 1:size(ANNe_reshape,4) % for loop for 10 compartments
D_minus = ANNe(:,:,1,i+1) + ANNe(:,:,2,i+1) + ANNe(:,:,3,i+1);
ID = ANNe(:,:,1,i) + ANNe(:,:,2,i) +ANNe(:,:,3,i); % adding all the elements
C(:,:,i) =((D_minus-ID)./D_minus);
end
It giving error:
Index exceeds matrix dimensions.
Error in Unti (line 16)
ID_minus = ANN(:,:,1,i+1) + ANNe(:,:,2,i+1) + ANNe(:,:,3,i+1);
Thanks.
0 个评论
采纳的回答
更多回答(1 个)
dpb
2014-10-19
You've got a bunch of different variable names -- I'm guessing there's the problem.
The error line has two--
Error in Unti (line 16)
ID_minus = ANN(:,:,1,i+1) + ANNe(:,:,2,i+1) + ANNe(:,:,3,i+1)
The first is ANN while the other two refer to ANNe
But your code snippet includes
ANe = reshape(ANN, ...
and
for i = 1:size(ANNe_reshape,4)
which reference two other unique variables which look like
a) a type and
b) something leftover from a previous piece of code, maybe???
Looks like you need to do a serious reading and cleanup of your m-file first.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!