0

I know that there are some well-known issues with indexing arrays in matlab. However, there is one in particular that I've never been able to understand:

This works just fine :

S =

     1     3     4     2
     4     5    24     1

v= S(1,:)

v =

     1     3     4     2

v(1)

ans =

     1

But this throws an error:

S(1,:)(1)
Error: ()-indexing must appear last in an index expression.

Why is this? I still don't understand from a high level why this doesn't work.
I am a CS student, so, if I could have the principle and/or concept driving this error, that'd be great. Thanks!

makansij
  • 9,303
  • 37
  • 105
  • 183
  • You can simply use `S(1,1)` – ThP Apr 28 '15 at 04:13
  • It's an error purely because the MATLAB language does not currently implement index cascading nor indexing on literals, save for structs and objects using dynamic field access (mostly because it's compulsory for full functionality in my view). It's just the language. – TroyHaskin Apr 28 '15 at 04:21
  • Okay, thanks to both of you. no "indexing on literals" makes sense. thanks. – makansij Apr 28 '15 at 04:27

0 Answers0