function s=plus(s1,s2)
%horizontal concatenation for char objects
if ischar(s1)&ischar(s2)
s=cat(2,s1).',s2).');
elseif isnumeric(s2)
s=double(s1)+s2;
else
error('Operator + Not Defined.')
end
It should work for adding two strings. I got an error message, in the book it is said that this M-file should be stored in @char directory just off of the MATLAB search path. I'm waiting to add these strings for example:'Hello'+'there'. Can anyone help?
why are you trying to complicate the things?? if you just wanted to concatenate two strings, then use "strcat' function. for more details, just type "help strcat" in MATLAB command prompt.
it works like below:
>> strcat('Hello', 'there..')
ans =
Hellothere..
if you want space between them, then give one extra sapce before the second word like below:
>> strcat('Hello', ' there..')