help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: numel(foo{:}) - feature or bug ?


From: Marco atzeri
Subject: Re: numel(foo{:}) - feature or bug ?
Date: Sun, 07 Aug 2011 18:05:58 +0200
User-agent: Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20110624 Thunderbird/5.0

On 8/6/2011 3:44 PM, Ben Abbott wrote:



 From my reading of the discussion, I'm skeptical that everyone understands 
that foo{:} is a cs-list, or maybe don't understand cs-lists? Consider the 
short example below ...

Calling it "comma separated list" is probably more clear. (IMHO)
Thanks for the clarification in any case.


        clear a
        foo = {"a", "ab", "abc", [1:4;5:8;9:12]};
        a(1).args = foo{1};
        a(2).args = foo{2};
        a(3).args = foo{3}
        a(4).args = char(foo{4});
        numel (a.args)
        ans = 72
        numel (foo{:})
        ans = 72
        numel (foo{1}, foo{2}, foo{3}, foo{4})
        ans =  72

Both foo{:} and a.args produce cs-lists (I added the char() function to avoid a 
syntax error).

Ben


I found very un-intuitive that the order matters a lot

        numel (foo{1}, foo{2}, foo{3}, foo{4})
        ans =  72
        numel (foo{2}, foo{3}, foo{4},foo{1})
        ans =  36
        numel (foo{3}, foo{4},foo{1},foo{2})
        numel (foo{4},foo{1},foo{2},foo{3})
        ans =  6

specially if one of the element is empty

        foo{1}=[]

        numel (foo{4},foo{1},foo{2},foo{3})
        ans = 0
        numel (foo{3}, foo{4},foo{1},foo{2})
        ans = 0
        numel (foo{2}, foo{3}, foo{4},foo{1})
        ans = 0
        numel (foo{1}, foo{2}, foo{3}, foo{4})
        ans =  72


but this is coming from the definition.
I wonder of the real usage of numel applied to a cs-list.

Marco





reply via email to

[Prev in Thread] Current Thread [Next in Thread]