octave-maintainers
[Top][All Lists]
Advanced

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

Re: goals for 3.1


From: John W. Eaton
Subject: Re: goals for 3.1
Date: Thu, 20 Mar 2008 13:37:45 -0400

On 20-Mar-2008, David Bateman wrote:

| John W. Eaton wrote:
| > I'm not sure about additional fucntions but in addition to working on
| > numeric data, these functionns should also work on character, struct,
| > and cell arrays.
| >
| >   
| 
| There is a compatibility issue with the triu, tril and diag functions
| with structure arrays between Octave and Matlab. Basically Matlab
| doesn't allow structure arrays with these functions, but Octave does..
| However what is returned by Octave doesn't really make any sense.. Consider
| 
|  d =  triu (struct ('fld',num2cell([1,2;3,4])))
|  d(2,1).fld
| 
| The triu on the struct returns the cell (2,1) with an empty octave-value
| and so d(2,1).fld returns nothing. This is quite a surprising and
| probably useless feature.. Similar issues exist in tril and diag. Should
| we keep this feature, it which case it should be documented, or should
| we just fail for structures like Matlab does?

Yes, since there is no "0" for structure arrays, probably we should
not expect these functions to work for structs.  For cell arrays, we
could make them work if we agree that "[]" is the "0" for cells.
I.e., given

  x = {1, 2, 3};

the function call

  diag (x)

would produce

  { 1, [], [];
   [],  2, [];
   [], [],  3 }

I think this is compatible behavior.

jwe


reply via email to

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