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!