how to construct a cell array from another cell array
古いコメントを表示
I have a cell array with a variable number of cells and a variable number of elements within each cell. For instance, it could by V{1}{1}=1 2 3 4, V{1}{2}=3 4 1 0,V{1}{3}=3 5 -1 -9, and V{2}{1}=-1 -2 9, V{2}{2}= 0 9 6, i.e., the cell 1 has 3 vectors of length 4 elements and the cell 2 has 2 vectors of length 3. I want to construct another cell array such that it has all combinations of these vectors, here I could have 6 combinations (3*2=6). The new cell array has to be of length 6 cells (number of possible combinations), and each cell has a possible combinations, for example A{1}={1 2 3 4 and -1 -2 9} and A{2}={1 2 3 4 and 0 9 6} . Note that I will get these vectors from a matlab code so I do not know them in advance.
3 件のコメント
Adam Danz
2019 年 8 月 15 日
It would be easier if we had data to play with (instead of having to construct fake data ourselves and risk getting it wrong).
mohamed Faraj
2019 年 8 月 15 日
Adam Danz
2019 年 8 月 15 日
I set up some demo data "V" that fits your description and the output "D" also fits your description (see answers). If this doesn't fit your goal, please update us on how your data or your goal differs.
採用された回答
その他の回答 (1 件)
カテゴリ
ヘルプ センター および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!