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
  1 件のコメント
Shannon
Shannon 2020 年 4 月 11 日
Thank you so much! You are so fast!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Types についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by