14

Damn you Matlab why don't you have i++ operator and ternary operator >:(

Comments
  • 6
    And why don't you start indexes at zero...
  • 4
    @Bennerant I have a theory about that actually... Matlab started as a tool for matrix operations and they are indexed from 1 because mathematicians, on the other hand C arrays are ultimately pointers and therefore the first item is at ptr+0 aka index 0... It might be only an observation but still kinda interesting
  • 1
    @karnivol that’s entirely the reason for the indexing.

    I imagine the addition in place and ternary if stuff being missing is also down to its mathematician user base.
  • 2
    While I'm at it... If you try "i++" it tells you that you probably meant "i = i + 1" so it knows what you want to do then why doesn't it just do it
  • 0
    *mutters about Ivory towers*
  • 1
    Increment operator is overrated
  • 0
    Read Steven Lord’s answer here, he explains it pretty well: https://groups.google.com/forum/m/...
  • 0
    @MrJimmy I’m working on a project that involves MATLAB (and lots of matrices and vectors) and from what I can tell, it is actually row-based when dealing with the aforementioned data structures.

    Now, when dealing with the meshgrid function, it gets kind of funky. meshgrid takes either two or three 1-D vectors and creates a 2D grid or a 3D grid from a sort of linear combination. It uses the first vector as the X-axis and uses the second vector as the Y-axis, ...

    The somewhat convoluted part is that it repeats the first vector (row-wise) the same number of times as the size of the second vector. And it repeats the second vector (column-wise) the same number of time as the size of the first vector.

    It still follows the row-order column but in this way, I think MATLAB is slightly annoying.
Add Comment