How to add zeros in cell of string
6 次查看(过去 30 天)
显示 更早的评论
Hello, I have 6x1 cell of string
'10'
'00'
'11'
'011'
'0101'
'0100'
how do i change it to
'10000000'
'00000000'
'11000000'
'01100000'
'01010000'
'01000000'
Thanks!
0 个评论
采纳的回答
Cameron
2023-1-3
OrigCell = {'10';
'00';
'11';
'011';
'0101';
'0100'};
zeroCell = cell(length(OrigCell),1);
zeroCell(:,1) = {'00000000'};
for xx = 1:length(OrigCell)
zeroCell{xx,1}(1:length(OrigCell{xx,1})) = OrigCell{xx,1};
end
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Characters and Strings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!