Indexing of cell array containing class

3 ビュー (過去 30 日間)
Andrea Stevanato
Andrea Stevanato 2018 年 6 月 19 日
コメント済み: Fangjun Jiang 2018 年 6 月 19 日
It's possible to index property of class that it's in cell array. If i have a class with a property value and i have a cell array that containig one instances of class for each cell there is a way to do (like a struct):
{cell.value} or [cell.value]

採用された回答

Fangjun Jiang
Fangjun Jiang 2018 年 6 月 19 日
I tried this. It looks better to construct an array of objects, not a cell array of objects.
a=[timer,timer]
a.Period
c={timer,timer}
c{1}.Period
c.Period
  2 件のコメント
Andrea Stevanato
Andrea Stevanato 2018 年 6 月 19 日
I already tried this and it doesen't work!
Fangjun Jiang
Fangjun Jiang 2018 年 6 月 19 日
What do you mean " it doesn't work"?
My example was trying to suggest putting multiple objects of a class into an array (using []), not a cell array (using {}). Then you can get the same property of the multiple objects in one shot like a.Period above.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStructures についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by