필터 지우기
필터 지우기

Error when appending object to empty array

조회 수: 1 (최근 30일)
Liyuan
Liyuan 2019년 5월 2일
편집: Liyuan 2019년 5월 2일
I am trying to form an array of a particular type of object, specifically the output model from fitdiscr, ClassificationDiscriminant.
Right now I am trying to do the following way:
model_cache = []
for i = 1:10
model = fitdiscr(...)
model_cache = [model_cache; model];
end
But this gives me the error
Undefined function 'throwNoCatError' for input arguments
of type 'double'.
Error in
classreg.learning.internal.DisallowVectorOps/vertcat
(line 49)
function a = vertcat(this,varargin),
throwNoCatError(this); end
Error in main_crossvalidate_sessions (line 84)
model_cache = [model_cache;model];
Which in plain english means I cannot concatenate a double with an object ([] is a double). How do I solve this issue? The way I can think of is ugly - when i = 1, model_cache = [model]; then in subsequent iterations append as usual. Are there simple solutions?
  댓글 수: 1
Liyuan
Liyuan 2019년 5월 2일
Seems possible to do with cells, but I'm still curious, is there any way to do this with arrays, like an array of structures?

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

답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by