MATLAB strings are stored internally as 2 bytes per character, not 1 byte per character. For regular ASCII text, that means that one of those bytes will be 0 (i.e., a null character). So in your for-loop you are actually only copying half the string, and every other byte you are copying is a null character. So the mxCreateString function only sees the first character (the 2nd being the first null character). Hence only 1 character gets copied in the mxArray you are creating. Some options:
1) Skip all the character-by-character copying and just use what you want, since it is already in mxArray form (recommended):
2) Use an official API function to do this. E.g. (maybe you need the text as a C-string for some reason),
character *string;
string = mxArrayToString(stringMX);
callInput[0] = mxCreateString(string);
mxFree(string);
You can do the character-by-character copying manually, but you would have to copy every-other-character of the input and then tack on the null character yourself, ensuring that you don't run over the end of the input string during the copy (i.e., don't hard code a 49).
Best Answer