필터 지우기
필터 지우기

Divide a big matrix into submatrices or cell

조회 수: 4 (최근 30일)
Michail Isaakidis
Michail Isaakidis 2019년 1월 23일
댓글: Michail Isaakidis 2019년 1월 23일
Hello all!
I want to save some of my big matrix elements into a cell array, with the main purpose of dividing them into sub matrices. The cell must contains only some numbers of the big matrix (those who belongs to one of the winning classes). For example if I have 100 classes in total and 4 winning classes I want my new matrices inside the cell containing only elements from the four winning classes. In my current code I have a problem using the end+1 command, getting an error Index exceeds array bounds. Do you have any suggestion how could I fix it?
Here follows my code:
CellArray={};
for i=1:length(Matrix)
for j=1:1:length(WinningClass)
if Matrix(i,5) == WinningClass(j,1)
CellArray{j}(end+1,1:4)= Matrix(i,1:4);
end
end
end

채택된 답변

KSSV
KSSV 2019년 1월 23일
  댓글 수: 1
Michail Isaakidis
Michail Isaakidis 2019년 1월 23일
Solved, it just need an empty cell array declaration on top

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by