How to remove spaces from a string using while if or for/
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Ervin DeBoy
il 19 Ott 2020
Commentato: Ameer Hamza
il 19 Ott 2020
Need to use for if or while , finding the length will probably help initiate the loop , but how to remove spaces its complicated
c = 'that is some tick stuf f f'
l = length(c)
for a = 0:l
if c == ' '
c==''
end;
disp(c)
0 Commenti
Risposta accettata
Ameer Hamza
il 19 Ott 2020
It is important that you traverse the string from the end toward the beginning.
c = 'that is some tick stuf f f';
l = numel(c);
for a = l:-1:1
if c(a) == ' '
c(a) = [];
end
end
disp(c)
2 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Data Type Conversion in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!