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)

추가 답변 (0개)

카테고리

Help CenterFile 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