String Copying without Spaces
12 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
i have a string a= [a b c d] separated by two spaces n i want to copy it in another string like b=[abcd] by removing the spaces. Please help.
0 Commenti
Risposta accettata
Andrei Bobrov
il 14 Mag 2012
a = 'a b c d'
b = regexprep(a,' ','')
or
b = setdiff(a,' ')
or
b = f(~ismember(a,' '))
or
b = strrep(a,' ','')
2 Commenti
Jan
il 14 Mag 2012
Or:
b = a(~isspace(a));
b = a(a ~= ' ');
b = a; b(strfind(b, ' ')) = [];
I assume, that the STRREP method is the fastest.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su String Parsing in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!