Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
karnivol1097y@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
-
Brolls31557y@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. -
karnivol1097yWhile 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
-
Read Steven Lord’s answer here, he explains it pretty well: https://groups.google.com/forum/m/...
-
enoon4317y@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.
Damn you Matlab why don't you have i++ operator and ternary operator >:(
rant