getting sum of class properties from a matrix

3 ビュー (過去 30 日間)
tombola
tombola 2011 年 11 月 30 日
Hi, if I make a simple class;
MATLAB code
classdef ExampleClass < handle
properties
fileCount = 0;
end
end
And I make a collection of them;
MATLAB code
myCollection=[ExampleClass1; ExampleClass2; ExampleClass3; ExampleClass4];
Is there an easy way to get the sum of the fileCount without iterating please? is, totalFileCount = sum(myCollection.fileCount)?
Also, is there an easy way to get the sum where the fileCount has a certain value? ie, totalFailCount = sum(myCollection.fileCount == 0)?
Any help appreciated! Everything I do with sum I get invalid arguments.

採用された回答

Daniel Shub
Daniel Shub 2011 年 11 月 30 日
You should be able to do:
sum([myCollection.fileCount])
and
sum([myCollection.fileCount] == 0)
Note the [].
  1 件のコメント
tombola
tombola 2011 年 11 月 30 日
THANKS!!!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeThird-Party Cluster Configuration についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by