MATLAB Answers

matlab space error problem

3 views (last 30 days)
Maria
Maria on 28 May 2020
Commented: Maria on 29 May 2020
does anyone know why my output doen't have space between two words

  11 Comments

Show 8 older comments
Maria
Maria on 28 May 2020
So this is right?
Brent Kostich
Brent Kostich on 28 May 2020
Did you not write this function? If you are asking me if your own test case is right, then I take it you have no idea what that code is doing.
If that is true, then no one can help you.
Maria
Maria on 29 May 2020
gotcha it. I used horzcat instead of stracat and it works ! thanks !

Sign in to comment.

Answers (2)

Fangjun Jiang
Fangjun Jiang on 28 May 2020
From "help strcat"
For character array inputs, strcat removes trailing ASCII white-space
characters: space, tab, vertical tab, newline, carriage return, and
form-feed. To preserve trailing spaces when concatenating character
arrays, use horizontal array concatenation, [s1, s2, ..., sN]

  0 Comments

Sign in to comment.


Steven Lord
Steven Lord on 28 May 2020
You can use concatenation as Fangjun Jiang and Brent Kostich suggested. I'd probably use join instead.
join(["I", "love", "Georgia", "Tech"])

  0 Comments

Sign in to comment.