Question regarding cell to string conversion

1 vue (au cours des 30 derniers jours)
Sameer
Sameer le 7 Août 2014
Commenté : Sameer le 7 Août 2014
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

Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 7 Août 2014
Modifié(e) : Azzi Abdelmalek le 7 Août 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)

Plus de réponses (0)

Catégories

En savoir plus sur Characters and Strings dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by