how to extend each element in a cell string array to fixed size?

조회 수: 3 (최근 30일)
Shannon
Shannon 2020년 4월 11일
댓글: Shannon 2020년 4월 11일
I have a cell string array A={'123', '4567', 67894'}, I want to extend each element to a fixed size, like size of 8, and fill in '0' in front. Like: A={'00000123', '00004567', '00067894'}. Can I get help? Thanks!

채택된 답변

David Hill
David Hill 2020년 4월 11일
for k=1:length(A)
A{k}=[repmat('0',1,8-length(A{k})),A{k}];
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Types에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by