matlab space error problem
Show older comments
does anyone know why my output doen't have space between two words


11 Comments
Brent Kostich
on 28 May 2020
What exactly are the inputs twisted4 and seg4?
Brent Kostich
on 28 May 2020
More to your question, strcat removes any trailing white-space. If you have trailing white-space use horzcat instead. My guess is that you don't have any leading or trailing white-space, in which case you will have to add it into the looping routine.
Maria
on 28 May 2020
Brent Kostich
on 28 May 2020
What exactly is your function supposed to do?
Maria
on 28 May 2020
Brent Kostich
on 28 May 2020
I think I understand what you are trying to do, but I think you need more code to achieve your desired result. If you give me an example for str and segment I can show you the fix.
Maria
on 28 May 2020
Brent Kostich
on 28 May 2020
Edited: Brent Kostich
on 28 May 2020
That example works because all you need to do is move the 'od' to the end.
If you removed the space so it was 'RaodpG', then your anwer would be 'RapGod'
The function would only work on very specific cases, it would not work on general cases.
Maria
on 28 May 2020
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
on 29 May 2020
Answers (2)
Fangjun Jiang
on 28 May 2020
0 votes
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]
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"])
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!