Why does this work in matlab'?
>>205370
Never used matlab, but I suppose that they use strings as arrays of chars and apply operations on an array for each element, just like you can write
A+1 = { x + 1 : x in A }
But what is the -'0' doing?
>>205394
like in C, subtracts the numeric value of the '0' character (which is 48 in ASCII).
So you get '1' - '0' = 49 - 48 = 1 in ASCII and so on.
>>205393
Yes everything, ABSOLUTELY EVERYTHING is an array in Matlab. Strings don't exist, only arrays of characters, and '123' is a 1-by-3 char array.
>>205394
>>205407
Yes, so what happens is that '0' is a 1-by-1 char array, and all 1-by-1 arrays are expanded into n-by-m arrays when added to, substracted from, element-by-element multiplied with, or element-by-element divided by n-by-m arrays.
So the '123' - '0' operation is expanded into '123' - '000', and again these are char arrays i.e. ['1' '2' '3'] - ['0' '0' '0'], and then the difference of ASCII codes is performed as explained by the other anon
>>205370
because matlab loves to default to doubles