Sum of empty matrix
Ältere Kommentare anzeigen
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 Kommentar
Thomas
am 30 Mär. 2012
Antworten (2)
the cyclist
am 30 Mär. 2012
0 Stimmen
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
am 30 Mär. 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.
Kategorien
Mehr zu Matrices and Arrays finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!