Index exceeds matrix dimensions
Show older comments
HI.
I've encouter an issue with Matlab.
I've a function which have for purpose to find in a dir take in input of the function the most recent dir/file in it and put the path of this dir/file in output.
I must run it with a 2015 MCR (Matlab compiler runtime) i've no problemes when i run it on Matlab 2020.
But when i try to run it with my 2015x Matlab version this msg came :
Index exceeds matrix dimensions (line where is the condition if)
Error in table/dotParentReference (l82)
Here is my code :

How can the index exceeds the matrix dimensions ?
Indeed i search dossier_a__chercher.datenum as many times i have dir/file in my current dir.
Nota : dossier_a_chercher_.datenum is a collumn. Do someone know if in the 2015 Matlab version we were able to acced at an element of a column like an element of a list as we can do with the current version ?
Sry for my english i hope this issue will be understandable
It would be very nice if someone has something to try !
Thx
5 Comments
Jorg Woehl
on 10 Mar 2021
Hi Tom, that's indeed strange... I would suggest checking the following:
- What's the value returned for nombre_dossier inside the function (line 2)? Just to make sure that it's not 0 and indeed corresponds to the number of files/folders in dossier.
- What is the value for i when the error occurs? You can use the debugger, or simply add a line i (without semicolon) before the if statement.
the cyclist
on 10 Mar 2021
This does seem weird. You might also just check
length(dossier_a_chercher.name)
length(dossier_a_chercher.datenum)
to see if they give the same value ahead of the loop. I can't think of a circumstance in which they would give different values, but it might give a hint.
Tom Argentin
on 10 Mar 2021
Walter Roberson
on 11 Mar 2021
Was there a good reason to convert to a table instead of leaving it as a struct? It just means that you move the (i) indexing to the structure name instead of after the field name, and that you take length of the structure instead of length of the name field.
Tom Argentin
on 11 Mar 2021
Accepted Answer
More Answers (0)
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!