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))
1 件のコメント
Mohammad Abouali
2014 年 12 月 12 日
I like this approach.
カテゴリ
ヘルプ センター および 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!