Concatenate cell data in an array

조회 수: 2 (최근 30일)
Pieter
Pieter 2013년 4월 19일
Good day,
I have got a cell which looks something like:
c{1} = [2 3
1 3
9 1
9 8
. .
. .]
c{2} = [1 2
3 1
. .
. .]
and so on.
Now I would like to vertically concatenate all data in one array.
The code I am using is:
total = []
for i = 1:size(c,2)
total = [total; c{i}];
end
This works fine, however Matlab suggests preallocation for speed. However, I don't know how to do that in this example.
Thank you in advance.

채택된 답변

Matt J
Matt J 2013년 4월 19일
Just do
total=vertcat(c{:})
  댓글 수: 1
Pieter
Pieter 2013년 4월 19일
Great, thanks a lot!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by