help-octave
[Top][All Lists]
Advanced

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

Re: how to test empty struct?


From: Jaroslav Hajek
Subject: Re: how to test empty struct?
Date: Sun, 14 Nov 2010 20:59:11 +0100

On Thu, Oct 28, 2010 at 11:19 PM, John W. Eaton <address@hidden> wrote:
> On 28-Oct-2010, John W. Eaton wrote:
>
> | On 28-Oct-2010, Eric Chassande-Mottin wrote:
> |
> | | how does one test that a structure array is empty?
> | | it does not seem possible with the usual function
> | | for vectors.
> | |
> | | a=struct; length(a), isempty(a)
> | | ans =  1
> | | ans = 0
> |
> | If you want an empty struct array, you have to write
> |
> |   struct ([])
> |
> | Things are done this way for Matlab compatibility.
>
> It occurred to me you might also be asking how to find the number of
> fields in a structure instead of asking about its array dimensions.
> There is no function specifically for that, so you currently have to
> write something like
>
>  numel (fieldnames (s))
>
> But maybe it would be worth having a separate function like numfields
> to do this job.
>

help nfields :)

I think it's been even in NEWS...



reply via email to

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