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 日

0 投票

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 件)

カテゴリ

ヘルプ センター および File Exchange で Characters and Strings についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by