1

I am a bit puzzled by the following MATLAB behavior: After defininf my matrix

g = ones(5)

I do not understand why these expressions makes sense

g(false)=3 # leaves g unchanged
g(true)=3 # g(1,1) is changed to 3 

while this syntax

g(0)=3 # provides error "Array indices must be positive integers or logical values."
g(1)=3 # g(1,1) is changed to 3 

I do not understand what the "g(false)" is exactly doing. Any hinsight would be of help.

Looking in Matlab support, very long, not focused.

Luis Mendo
  • 110,752
  • 13
  • 76
  • 147
EarlGrey
  • 126
  • 5
  • 2
    For a matrix `g`, `g(false)` uses a combination of logical and linear indexing. See [here](https://www.mathworks.com/company/newsletters/articles/matrix-indexing-in-matlab.html) or [here](https://stackoverflow.com/questions/32379805/linear-indexing-logical-indexing-and-all-that) – Luis Mendo Aug 11 '23 at 11:43

0 Answers0