Array of ClassificationTree objects
조회 수: 3 (최근 30일)
이전 댓글 표시
I am very new to MATLAB. I was trying to train some ClassificationTree's and the assign them in array with the following snippet
for k = 1:rows
tree=ClassificationTree.fit(data(1:k, 1:cols),labels(1:k));
ensemble(k)=tree;
end
however when I run this I get following error
??? Error using ==> DisallowVectorOps>DisallowVectorOps.subsasgn at 28
You cannot assign to an object of class double using () indexing.
Error in ==> dwm02 at 7
ensemble(k)=tree;
is there any way of doing this? MATLAB help on object arrays is a bit confusing..
채택된 답변
Ilya
2012년 6월 6일
Use a cell array. Pre-allocate the array by
ensemble = cell(rows,1);
And then assign using curly brackets:
ensemble{k} = tree;
댓글 수: 2
Walter Roberson
2012년 6월 7일
It is not absolutely necessary to pre-allocate: it is a matter of efficiency.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Classification Ensembles에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!