In Matlab, the following statement gives a numeric output . .
>> 'abc' + 'def'
ans =
197 199 201
In C++, the output of the following
std::string("abc") + std::string("def")
…would give the arguably more useful…
abcdef
A little more exploration gives..
>> a = 'abc'
a =
abc
>> whos
Name Size Bytes Class Attributes
a 1x3 6 char
This suggests that my variable a is a char type. However, we know that this is not equivalent to a C type char, as it is an object that knows its size dimensions etc.
Therefore, my questions are:
What use would this numeric output be?
…leading to
Why would they design it to behave like that?
Because a string in Matlab is literally just an array of
chartype, so it’s equivalent to:It is not set in stone that
+means “concatenate”. If you want string concatenation in Matlab, you can always do: