Question regarding cell to string conversion

1 回表示 (過去 30 日間)
Sameer
Sameer 2014 年 8 月 7 日
コメント済み: Sameer 2014 年 8 月 7 日
Hello all
I have a cell called A which looks like
'E1'
'E34'
'E2'
'E12'
'E17'
'E33'
'E3'
'E11'
'E24'
'E16'
'E19'
'E32'
'E8'
'E35'
'E4'
'E10'
'E21'
'E26'
'E36'
'E15'
'E20'
'E31'
'E14'
'E7'
'E9'
'E37'
'E5'
'E22'
'E25'
'E27'
'E13'
'E30'
'E6'
'E23'
'E28'
'E29'
I want to convert from cell to string but I am not able to do so because of the different lengths each cell element.
Can anyone please guide me through this?
Regards

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 8 月 7 日
編集済み: Azzi Abdelmalek 2014 年 8 月 7 日
v={'E1'; 'E34'; 'E2';'E12'}
n=max(cellfun(@numel,v))
w=cellfun(@(x) [x repmat(' ',1,n-numel(x))],v,'un',0)
out=cell2mat(w)
%or simply
out=char(v)
  1 件のコメント
Sameer
Sameer 2014 年 8 月 7 日
Thanks a lot....

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by