[Top][All Lists]

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

Re: sum(null matrix) becomes null matrix not zero

From: John Eaton
Subject: Re: sum(null matrix) becomes null matrix not zero
Date: Thu, 27 May 93 14:12:19 EDT

: If I execute 
: >>a=[]
: >>b=sum(a)
: The result becomes b=[].
: Is this specification of octave?

It seems to me that any operation on an empty matrix should either
give you an error, or it should return an empty matrix.  You can
choose which you prefer by setting the value of the built-in variable
`propagate_empty_matrices' to either "true", "false", or "warn".

I suppose that a case could be made for treating the summation and
product functions as special cases (product should return 1?), but I
think it is probably better to try to avoid doing operations on empty

: I expected b became zero like MATLAB.

I didn't know that Matlab returned 0.  Are you sure that's not a bug
in Matlab?

Are there very many places where this is really useful?

John W. Eaton      | The exam demonstrates a comminuted, slightly overlapping
address@hidden | angulated fracture of the midfifth metatarsal.

reply via email to

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