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:
- 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.
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