Combining Cells into a single cell
이전 댓글 표시
How can I combine multiple cells in to a single cell
there are 6 cells, each m x n format (n is 17 in all)
I want a new cell created that just adds up below
so for example Cell1 is 50x17 Cell2 is 30x17 Cell3 is 20x17
new cell should then be : AllCell is 100x17
I thought of:
Allcell=cell(Cell1+Cell2+Cell3,17);
but what then
댓글 수: 4
You should find your way from there on, and combine content of cell arrays.
Jan
2013년 1월 9일
It slightly confusing: Do you want AllCell to be a scalar cell, which contains a 100x17 matrix?
Hello kity
2013년 1월 9일
편집: Hello kity
2013년 1월 9일
Jongyoung Song
2017년 1월 24일
AllCell = [Cell1; Cell2; Cell3];
채택된 답변
추가 답변 (1개)
Jan
2013년 1월 9일
If your cells are not called "Cell1", "Cell2", ... but you use an index as index (as suggested repeatedly and consequently in this forum), the concatenation is even easier:
C{1} = rand(50, 17);
C{2} = rand(10, 17);
C{3} = rand(40, 17);
C{4} = rand(30, 17);
C{5} = rand(20, 17);
AllC = {cat(1, C{:})};
댓글 수: 5
Image Analyst
2013년 1월 9일
편집: Image Analyst
2013년 1월 9일
Why even mess with cells, if it's just a simple numerical matrix at that point? Just simplify it
theBigArray = cat(1, C{:}); % A matrix, not a cell - simpler, yay!
Jan
2013년 1월 9일
But the OP asked for the output to be a cell explicitly: "Allcell=cell(...".
Image Analyst
2013년 1월 9일
Yeah, I know. But she's a beginner and beginners often think they want something when some other way is better, simpler, and easier. For example to get the 5th row, 16th column you could simply and naturally do theBigArray(5, 16). OR do something more complicated like AllCell(1){5, 16} or maybe it's just AllCell{5, 16} or something like that - I always have to play around with braces and parentheses til I get it right, that's why I avoid cell arrays if at all possible.
giri wira
2015년 6월 11일
thanks simon, very usefull
Pooja Patel
2017년 2월 24일
thank you so much mr.simon. this is working very well.
카테고리
도움말 센터 및 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!