MATLAB: Matlab “Index in position 1 is invalid. Array indices must be positive integers or logical values.”

index in position 1 is invalid. array indices must be positive integers or logical values.

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.

Best Answer

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.