Question regarding cell to string conversion

1 visualizzazione (ultimi 30 giorni)
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

Risposta accettata

Azzi Abdelmalek
Azzi Abdelmalek il 7 Ago 2014
Modificato: Azzi Abdelmalek il 7 Ago 2014
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)

Più risposte (0)

Categorie

Scopri di più su Characters and Strings in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by