Is it a mistake that the function sum?

조회 수: 10 (최근 30일)
Lonero Zhou
Lonero Zhou 2020년 2월 19일
편집: James Tursa 2020년 2월 19일
Please see the follow code:
N=3;
sum(sum(eye(N)-ones(N,N)/N))
The MATLAB answer is 3.3307e-16, but the right answer is 0.
But it is true if N is 2, 4, 8 as follows:
N=2;
sum(sum(eye(N)-ones(N,N)/N))
N=4;
sum(sum(eye(N)-ones(N,N)/N))
N=8;
sum(sum(eye(N)-ones(N,N)/N))
These right answers are 0, and the MATLAB answer is 0 too.

답변 (1개)

James Tursa
James Tursa 2020년 2월 19일
편집: James Tursa 2020년 2월 19일

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by