Sum of empty matrix
Mostrar comentarios más antiguos
The sum of an empty matrix does not always follow the rule 'sum(empty) = 0'. What's up with this?
>> sum(ones(1,0))
ans = 0
>> sum(ones(0,1),2)
ans = Empty matrix: 0-by-1
>> sum(ones(2,0))
ans = Empty matrix: 1-by-0
>> sum(ones(0,2),2)
ans = Empty matrix: 0-by-1
1 comentario
Thomas
el 30 de Mzo. de 2012
Respuestas (2)
the cyclist
el 30 de Mzo. de 2012
0 votos
I don't think this answers your question, but it does give some related info: http://blogs.mathworks.com/loren/2009/11/04/calculus-with-empty-arrays/
Jan
el 30 de Mzo. de 2012
Especially:
sum(ones(1, 0)) % 0
sum(ones(2, 0)) % Empty matrix: 1-by-0
is not intuitive anymore. Please contact the technical support and ask for an enhancement.
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!