String Copying without Spaces

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.

 Respuesta aceptada

Andrei Bobrov
Andrei Bobrov el 14 de Mayo de 2012

0 votos

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

2 comentarios

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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Vehicle Dynamics Blockset en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

Ash
el 14 de Mayo de 2012

Community Treasure Hunt

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

Start Hunting!

Translated by