- Check the Size of edges: Ensure that the edges array is properly initialized and has the expected dimensions.
- Check the Indexing Variable: Make sure the indexing variable S used in subsref(edges, S); is within the valid range.
- Add Debugging Statements: Add print statements before the line causing the error to inspect the sizes and values of the arrays and indices.
code can not run
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
hi ,any one help me
in error
STARTING ACO SCRIPT ################
Index in position 1 exceeds array bounds. Index must not exceed 1.
Error in indexing (line 84)
out = subsref(edges, S);
Error in aco (line 113)
ACOallnodesinvolvedinpossiblepaths(counter,1)=ACOallpossibleshortestpaths(a).routes.Edges.EndNodes(b,1);
Error in run (line 99)
evalin('caller', strcat(script, ';'));
Error in main (line 328)
run aco.m
0 comentarios
Respuestas (1)
Pavan Sahith
el 4 de Ag. de 2024
Hello,
The error you're encountering, "Index in position 1 exceeds array bounds. Index must not exceed 1," suggests that you are trying to access an element in an array that does not exist. This often occurs when the indexing variable exceeds the size of the array.
Here's a general approach to debug and fix this issue:
Here's an example of how you might add debugging statements:
disp('Size of edges:');
disp(size(edges));
disp('Indexing variable S:');
disp(S);.
out = subsref(edges, S);
Adding some similar checks will help you identify if the array is being accessed out of bounds and allow you to debug further. Attaching your complete code will allow the community to help you better
0 comentarios
Ver también
Categorías
Más información sobre Matrix Indexing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!