How to delete spaces and '[ ', ']' characters from all data array string cells?

I need to remove the spaces and '[', ']' characters from the cells of a data array, I have try with the cellfun function and with:
a(a(1,1)== '[')='' %%where 'a' is the matrix, this case only for the first cell and '[' character
But is not working, How could be done?
Thank you in advance,

 採用された回答

Jan
Jan 2013 年 7 月 15 日

1 投票

Posting some example data would reduce the need to guess, what you exactly want.
CStr = {' This contains spaces ', 'This has some [ and ]'};
CStr = strrep(CStr, ' ', '');
CStr = strrep(CStr, '[', '');
CStr = strrep(CStr, ']', '');

その他の回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 7 月 15 日

1 投票

a={'',1 ,[],'22'}
a(cellfun('isempty',a))=[]

カテゴリ

ヘルプ センター および File ExchangeStructures についてさらに検索

質問済み:

2013 年 7 月 15 日

Community Treasure Hunt

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

Start Hunting!

Translated by