Matlab "Index in position 1 is invalid. Array indices must be positive integers or logical values."

31 visualizaciones (últimos 30 días)
I keep getting this error message
" Index in position 1 is invalid. Array indices must be positive integers or logical values.
Error in loop_Practice (line 48)
if x(i,j)>maximum(k) "
I am very new to Matlab, so I am not even sure what the error message is saying. Can anyone help me?
I have attached the matlab file.

Respuesta aceptada

Jon
Jon el 18 de Feb. de 2020
Editada: Jon el 18 de Feb. de 2020
The error is telling you that MATLAB thinks that the variable that you call maximum is a vector, and that you want to have element k of this vector, but k is not a positive integer, so the expression is not valid.
It looks like you want to find the maximum value of some elements. If so, you should be using the max function for this, not a variable called maximum.
If you include the rest of your code (please use the code button on the MATLAB Answers toolbar to format it nicely) it might be possible to see exactly what is going wrong.

Más respuestas (0)

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!

Translated by