How to initialize a vector of class handles?

前端 未结 3 2002
渐次进展
渐次进展 2021-01-14 05:04

I have a handle-based class that I need to create a vector of. An easy method of doing this is to dynamically construct the vector in a for loop, but this causes mlint

3条回答
  •  无人共我
    2021-01-14 05:58

    Having a default constructor the accepted answer is fine. Having no default constructor (HandleClass()) returns not enough input arguments) the best possibility I see is creating a cell first:

    foo=cell(1,10);
    for ix=1:10
        foo{ix}=HandleClass(ix)
    end;
    foo=[foo{:}];
    

提交回复
热议问题