editing in string array
6 ビュー (過去 30 日間)
古いコメントを表示
a={'10','7','5','9','11','12','12','4'}
I want to put 0 at the starting of all those whose length is 1. How can I do this easily?
0 件のコメント
採用された回答
KSSV
2017 年 11 月 1 日
編集済み: KSSV
2017 年 11 月 1 日
a={'10','7','5','9','11','12','12','4'} ;
L = cellfun(@length,a) ;
idx = L==1 ;
a(idx) = strcat('0',a(idx)) ;
3 件のコメント
KSSV
2017 年 11 月 1 日
cellfun works on the cells.....it is nothing but a for loop on each cell. arrayfun works on rows/ cols of matrices.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!