How to replace cell values with consecutive values related to their index
古いコメントを表示
For example:
a = 1x3 cell array
columns 1 through 3
{1x1} {1x5} {1x3}
I'd like to be able to replace the values in each cell array with consecutive values so that:
a = 1x3 cell array
{[1]} {[2 3 4 5 6]} {[7 8 9]}
Thanks!
採用された回答
その他の回答 (1 件)
Simpler:
C = {cell(1,1),cell(1,5),cell(1,3)}
N = cellfun(@numel,C);
D = mat2cell(1:sum(N),1,N)
1 件のコメント
dpb
2021 年 5 月 29 日
That's what I intended, but kept muffing the mat2cell syntax...it's always thrown me for a loop for some reason -- rarely ever use it I guess is likely cause.
カテゴリ
ヘルプ センター および File Exchange で Matrices and Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!