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.

 Akzeptierte Antwort

Andrei Bobrov
Andrei Bobrov am 14 Mai 2012

0 Stimmen

a = 'a b c d'
b = regexprep(a,' ','')
or
b = setdiff(a,' ')
or
b = f(~ismember(a,' '))
or
b = strrep(a,' ','')

2 Kommentare

Ash
Ash am 14 Mai 2012
Thanks alot for ur help...It worked..
Jan
Jan am 14 Mai 2012
Or:
b = a(~isspace(a));
b = a(a ~= ' ');
b = a; b(strfind(b, ' ')) = [];
I assume, that the STRREP method is the fastest.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Vehicle Dynamics Blockset finden Sie in Hilfe-Center und File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by