sum(null matrix) becomes null matrix not zero

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

sum(null matrix) becomes null matrix not zero

che6yoh
Dear Sirs,

I am very sorry to trouble often.

If I execute
>>a=[]
>>b=sum(a)
The result becomes b=[].
Is this specification of octave?
I expected b became zero like MATLAB.

I sent two other mails to [hidden email] already.

1. The results of expm are strange.
   Does the problem occure only on my system?

2. Is there any way to execute external programs from octave?

3. Is there any way to get ASCII code of each character in a
   string?

I am looking forward to getting reply from you.

Yoshihiro Hashimoto
Dept. of Systems Eng., Nagoya Inst. of Tech.
[hidden email]
[Now]Dept. of Chem. Eng., The Univ. of Leeds
[hidden email]
--------------------------------------------------------------
The mail to [hidden email] will be sent to
[hidden email] automatically.


       

Reply | Threaded
Open this post in threaded view
|

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

John Eaton-3
: 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
matrices.

: 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
[hidden email] | angulated fracture of the midfifth metatarsal.

Reply | Threaded
Open this post in threaded view
|

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

John Eaton-3
In reply to this post by che6yoh
: > I think, octave uses eigenvectors to calculate expm, it could fail for
: > some ill matrice.

Yes, Octave currently uses a fairly simple method based on eigenvalues
and eigenvectors to compute expm, logm, and sqrtm.  It's clearly not
sufficient, and needs to be improved.

: > However, MATLAB built-in expm function uses more general
: > and reliable algorithm.

Does anyone have a reference for the method used by Matlab?

I have a copy of Moler and Van Loan's paper `Nineteen dubious ways to
compute the exponential of a matrix', but it seems that there is some
kind of problem with every method, and that there is no clearly
superior way to do this computation.

Does anyone know of newer or better methods?

--
John W. Eaton      | The exam demonstrates a comminuted, slightly overlapping
[hidden email] | angulated fracture of the midfifth metatarsal.

Reply | Threaded
Open this post in threaded view
|

sum(null matrix) becomes null matrix not zero

che6yoh
In reply to this post by John Eaton-3
I am sorry to answer late.

  >:sum([])
  >: 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?
In MATLAB Identification Toolbox, it is used very often.
I could understand that sum([])=[] was better than sum([])=0.
It is not neccessary for me to get 0 as the result of sum([]).

ABS('string') and SETSTR(vector) is used to contain many system
parameters into one matrix in MATALB Toolboxes.
The type of a model is expressed in a string.
It is contained in a parameter matrix using ASCII codes.
 
I wanted to use many results of MATLAB in octave.
Are there many toolboxes which are still freeware and can be used
in octave?

Yoshihiro Hashimoto
Dept. of Systems Eng., Nagoya Inst. of Tech.
[hidden email]
[Now]Dept. of Chem. Eng., The Univ. of Leeds
[hidden email]
--------------------------------------------------------------
The mail to [hidden email] will be sent to
[hidden email] automatically.