Index exceeds the number of array error
Mostrar comentarios más antiguos
a = a certain 20x20 matrix;
[val,idx] = max(a(:));
[x, y] = find(a == val);
At the underlined part of the code, this displays the error "Index exceeds the number of array elements (1)". How to fix this?
3 comentarios
Chunru
el 31 de Mzo. de 2022
The result of 'find' may be empty so that x and y are empty. However idx is a positive number. This cause the problem.
Chunru
el 31 de Mzo. de 2022
Then x is a scaler and you cannot find x(idx) if idx is greater than 1.
Stephen23
el 31 de Mzo. de 2022
"x = 11 and y = 21 though"
And why do you expect that IDX should be able to index into scalar numerics?
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Matrices and Arrays en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!