MATLAB: How to insert space between strings while doing strcat string for eg: a='hello'; b='world'; strcat(a,b); strcat(a,b) gives 'helloworld' But I need it as 'hello world' How can I do that ? Best Answer Use the square bracket [] concatenation operator, and including a space variable is the easiest way:a='hello'; b='world'; s = ' ';Result = [a,s,b]Result =hello world Related SolutionsMATLAB: Is there a more efficient way to omit certain characters from a string without using loops One way would be newsf = regexprep(sf, '([CREP1-4]|SQ)', '') ;but what does "etc" encompass? MATLAB: Write a function that concatenated string as output a='hello';b='world';output = concantecater(a,b) % function callfunction output = concantecater(input1,input2) % function definitionoutput=sprintf('%s %s',input1,input2); % works for any stringsendGives:output = hello worlda='hi';b='there';sprintf('%s %s',a,b)Gives:ans = 'hi there'Or:[a,' ',b] Related QuestionFunction file that removes a character in a stringThere is no space after the equal sign? (fprintf)How to remove certain characters from a string in a fileConvert string to cell arrayDoes the STRCAT command remove the trailing spaces while performing a concatenation in MATLAB 7.4 (R2007a)Converting strings in cell array into array
Best Answer