How to get rid of spaces between string?
显示 更早的评论
I have to work out a way to remove the spaces in my morse code output. SO far I have something like this:
...
Word=input('Please enter a word:','s');
Word=upper(Word);
Valid=1;
str = ' ';
for Character=Word
switch Character
...
case ' '
Code='/';
otherwise
Valid=0;
end
采纳的回答
更多回答(1 个)
Guillaume
2014-12-12
The easiest to get rid of extra spaces:
s = 'a string with some weird spaces ';
t = strjoin(strsplit(s))
类别
在 帮助中心 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!