passing a cell array of objects to a method
古いコメントを表示
I'd like to send an array of objects to a method (n=1 to many). Is there a syntax that allows the first argument of a method to be a cell array of class objects? Of course this could be done with varargin and parsing inputs, but this seems more cumbersome than need be.
thanks
採用された回答
その他の回答 (1 件)
Walter Roberson
2011 年 7 月 18 日
0 投票
If this array is hetrogenous then is there a reason you are using a cell array instead of an array of the appropriate class?
If the array is homogenous then which element of the cell array should be examined in order to determine which object class is to be invoked?
2 件のコメント
Aaron Gruber
2011 年 7 月 19 日
Walter Roberson
2011 年 7 月 19 日
A cell array is not a class of anything other than "cell".
I suspect you would be better off defining a class which was a "collection" of your class objects. You could probably override horzcat() and vertcat() to give you semantics such as [] being able to construct the container class.
カテゴリ
ヘルプ センター および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!