strange Index exceeds matrix dimensions (MATLAB bug?)
1 view (last 30 days)
Show older comments
Hi all,
I have a function running in particular the following code (sI and tdii2 are matrices):
% debugging
class(sI) % double
class(tdii2) % uint32
size(sI) % 512 672
numel(sI) % 344064
min(tdii2(:)) % 1
max(tdii2(:)) % 343988 (not 391863)
save('temp55.mat', 'sI', 'tdii2');
% this line produces an error
imgvals = sI(tdii2);
When I run it, it breaks with
??? Index exceeds matrix dimensions.
Error in ==> backproject_single at 133
imgvals= sI(tdii2);
Even worse, when I execute this
load('temp55.mat', 'sI', 'tdii2');
imgvals= sI(tdii2);
in the console, it works perfectly fine.
I am totally puzzled.... Has anyone an idea what the cause could be?
Thanks Thomas
0 Comments
Answers (1)
Matt Fig
on 6 Jun 2011
If size(sI) is as you say, then indexing into it with values greater than 512*672 = 344064 should indeed cause an error!
max(tdii2(:)) > (512*672) % Returns true using 391863 for L.H.S.
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!