split matrix

조회 수: 7 (최근 30일)
Bayan
Bayan 2012년 2월 14일
we have matrix as 801* 3 and we need to split or divide this matrix to parts as 100 * 3 , the rest of matrix after split must be put in matrix also How ???

채택된 답변

Andrei Bobrov
Andrei Bobrov 2012년 2월 14일
A = randi(1800,801,3);% A - Let your matrix.
A1 = A(1:end-1,:); % for this is case - size of A - [801x3]
outDouble3d = permute(reshape(A1.',3,100,[]),[2 1 3]);
or
outCell = mat2cell(A,[100*ones(fix(size(A,1)/100),1);1],3)
ADD
n = 89;
[m,k] = size(A);
t = rem(m,n);
if ~t, t = []; end
outCell = mat2cell(A,[n*ones(fix(m/n),1);t],k)

추가 답변 (1개)

Bayan
Bayan 2012년 2월 14일
thanks a lot ; but another problem is show : when i change 100 to another number as 89 this error appear :
_Error using ==> mat2cell at 116 Input arguments, D1 through D2, must sum to each dimension of the input matrix size, [801 3]. _
  댓글 수: 1
Andrei Bobrov
Andrei Bobrov 2012년 2월 14일
look at ADD in my answer

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

카테고리

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