String Copying without Spaces

12 次查看(过去 30 天)
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.

采纳的回答

Andrei Bobrov
Andrei Bobrov 2012-5-14
a = 'a b c d'
b = regexprep(a,' ','')
or
b = setdiff(a,' ')
or
b = f(~ismember(a,' '))
or
b = strrep(a,' ','')
  2 个评论
Ash
Ash 2012-5-14
Thanks alot for ur help...It worked..
Jan
Jan 2012-5-14
Or:
b = a(~isspace(a));
b = a(a ~= ' ');
b = a; b(strfind(b, ' ')) = [];
I assume, that the STRREP method is the fastest.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 String Parsing 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by