|
From: | Bård Skaflestad |
Subject: | Re: Counting entries in cs-lists |
Date: | Wed, 22 Apr 2015 12:33:11 +0200 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 |
On 22/04/15 12:09, JokerOne wrote:
Is there a one-line solution to count the entries of a cs-list, e.g.a(1).b.c = [1;2]; a(2).b.c = [3;4;5];Now: desired_function_or_line(a.b.c) is suppose to yield : 5
I don't have a one-liner, but the following produces the result that I think you want. Do note, however, that this sequence is not general as it is *very* much dependent on knowing the exact shapes of your objects. The underlying technique is nevertheless applicable in other, similar situations.
ab = [ a.b ]; cnt = numel(vertcat(ab.c)) Sincerely, -- Bård Skaflestad <address@hidden> SINTEF ICT, Applied Mathematics
[Prev in Thread] | Current Thread | [Next in Thread] |