electroabdo
Junior Member level 2
Hello,
I tried this matlab code:
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?
I tried this matlab code:
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?