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
-
You know matlab! Question for you!
Is there a reason that array indexes start at 1 and not 0? -
@cmarshall10450 To be fair: The famous TI graphical calculators don't do that, too. And nobody complains about that. I would argue that more people have used a TI calc than matlab.
That point personally seems silly to me. The reason of counting from 0 is probably because in C arrays are a pointer to the first element and you increment the value by a given number of bytes * sizeof type.
I'm not aware of any other reason for doing it this way and while it is totally normal for us, it isn't for many other people.
Matlab focusing more mathematicians rather than programmers has not an inherently bad choice for choosing that.
No offence, just want to clarify that bit. -
fuckwit12165y@cmarshall10450 @LinusCDE because of vectors in math (which are indexed by numbers starting with 1)most languages specifying on statistics, and complex mathematical computation adapted that approach for their arrays. Because using an array to display your vector and constantly subtracting 1 to convert mathematical index to byte offset got annoying fast
-
@cmarshall10450
Mathlab uses C++ libs and java for the front end. Deep down if counts from 0 but it shows that it counts from 1 to make mathematicians happy. -
@Gregozor2121 @fuckwit @LinusCDE thanks for the clarification. It makes sense to start from 1 with mathemaitions being the main users. I just remember one of my colleagues having to convert some geological calculations written in matlab to python and he was really confused as to why the first element was always being ignored until he discovered the indexing difference.
*finishes MATLAB course*
My blanket when I wake up and think about my expired license which I won't renew:
joke/meme