concatenate all cells in a celll array
4 ビュー (過去 30 日間)
古いコメントを表示
hello i have a cell array 7x7
Columns 1 through 6
[256x1 double] [256x1 double] [256x1 double] [256x1 double] [256x1 double] [256x1 double]
[256x1 double] [256x1 double] [256x1 double] [256x1 double] [256x1 double] [256x1 double]
[256x1 double] [256x1 double] [256x1 double] [256x1 double] [256x1 double] [256x1 double]
[256x1 double] [256x1 double] [256x1 double] [256x1 double] [256x1 double] [256x1 double]
[256x1 double] [256x1 double] [256x1 double] [256x1 double] [256x1 double] [256x1 double]
[256x1 double] [256x1 double] [256x1 double] [256x1 double] [256x1 double] [256x1 double]
[256x1 double] [256x1 double] [256x1 double] [256x1 double] [256x1 double] [256x1 double]
Column 7
[256x1 double]
[256x1 double]
[256x1 double]
[256x1 double]
[256x1 double]
[256x1 double]
[256x1 double]
I want to concatenate all t he cells in this cell array to a 7x7x256=12544x1 vector how do i do that ?
0 件のコメント
採用された回答
Image Analyst
2016 年 7 月 17 日
Try this:
ca = ca{:}
4 件のコメント
Image Analyst
2016 年 7 月 17 日
You're welcome, though you should really not even use cell arrays in the first place. They are for using mixed data types (though this has been supplanted by the new "table" data type in most cases), or for arrays of strings of different lengths. They were not meant for arrays of simple numerical arrays, which could be handles by a simple 2D numerical array in your case.
その他の回答 (1 件)
Azzi Abdelmalek
2016 年 7 月 17 日
編集済み: Azzi Abdelmalek
2016 年 7 月 17 日
a=arrayfun(@(x) rand(256,1),ones(7),'un',0)
out=reshape(cell2mat(a),[],1)
3 件のコメント
Azzi Abdelmalek
2016 年 7 月 17 日
Image Analyste I don't understand the thanks for what? but I agree with you that some choices are really incomprehensible!
Image Analyst
2016 年 7 月 17 日
Well, you used reshape() and I did the "for" loop. While a for loop might be easier for beginners to understand, reshape() is possibly the more "MATLAB-ish" way to do it. And it can be complicated/confusing to figure out when to use brackets, braces, and parentheses with cell arrays, even for us experienced people that's why I recommend beginners to avoid them if they can.
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!