Sum of empty matrix
古いコメントを表示
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
回答 (2 件)
the cyclist
2012 年 3 月 30 日
0 投票
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
2012 年 3 月 30 日
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.
カテゴリ
ヘルプ センター および File Exchange で Matrices and Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!