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!