How to get rid of spaces between string?
Ältere Kommentare anzeigen
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
Akzeptierte Antwort
Weitere Antworten (1)
Guillaume
am 12 Dez. 2014
The easiest to get rid of extra spaces:
s = 'a string with some weird spaces ';
t = strjoin(strsplit(s))
1 Kommentar
Mohammad Abouali
am 12 Dez. 2014
I like this approach.
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!