필터 지우기
필터 지우기

split a cell matrix into sub-matrices

조회 수: 1 (최근 30일)
pavlos
pavlos 2014년 3월 12일
댓글: per isakson 2014년 3월 12일
Hello,
Please help me with the following:
Consider a 3x1 cell matrix called C, where
each cell element contains matrices with different number of rows, for example:
C{1,1}=a 100x10 matrix
C{2,1}=a 20x10 matrix
C{3,1}=a 30x10 matrix
How can I extract separate different sub-matrices (maybe with a for loop)?
For example,
for i=1:3
submatrix(i)=mat2cell(C(i,1));
end
I need 3 different sub-matrices.
Thank you very much.
Pavlos

채택된 답변

per isakson
per isakson 2014년 3월 12일
편집: per isakson 2014년 3월 12일
Hint:
>> C{1,1} = rand(100,10);
>> sub = C{1,1}( [2:4], [1:6] )
sub =
0.5576 0.4866 0.3355 0.2928 0.9422 0.0570
0.1532 0.3821 0.1126 0.8330 0.5177 0.8108
0.7899 0.6946 0.6691 0.9563 0.4559 0.6544
>>
  댓글 수: 2
pavlos
pavlos 2014년 3월 12일
Thank you for your response.
I am interested in indexing the sub variable with an automated process through a for loop.
I want 3 separate matrices, for example maybe something like this:
for i=1:3
sub(i) = C{i,1}...
end
and the result will be
sub1=...
sub2=...
sub3=...
Each sub would refer to matrix with different number of rows.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by