Function: copystructure

CALL:

copyto = copystructure(copyfrom, copyto)

DESCRIPTION:

Kopieer inhoud van de ene naar de andere structure, maar houd oorspronkelijke volgorde van velden vast. Indien nodig worden nieuwe velden toegevoegd

INPUT:

copyfrom any
structure with overrides
 NOTE: "copyfrom" should support methods "fieldnames" and
       "subsasgn". Therefore undoredo objects are allowed here.

copyto any
structure with overridable data

OUTPUT:

copyto any
     adapted structure

NOTE 20140418
For the function @panel/setInit copystructure(copyfrom,copyto) behaves in
an undesired way if fields in either copyfrom or copyto is an array of
structures.

DISCUSSION (2009 02 06)
    What should be done in the following cases?
    "S=copystructure(copyfrom[N],copyto[M])"
    N=M=1    ==>
        straightforward
    N=0    ==>
        return copyto
    M=0    ==>
        return copyfrom
    N>1, M=1 ==>
        this is equivalent to:
        for k=1:N
            S(k)=copystructure(copyfrom(N),copyto)
        end
        Size of output equals size(copyfrom)
    N=1, M>1 ==>
        this is equivalent to:
        for k=1:M
            S(k)=copystructure(copyfrom,copyto(M))
        end
        Size of output equals size(copyto)
    N>1, M>1, N==M ==>
        Size of output equals size(copyto)
    N>1, M>1, N~=M ==>
        This should generate an error
        Current behavior: copyto(2:end) is ignored