フィルターのクリア

sum command giving ridiculous answer

2 ビュー (過去 30 日間)
Brian
Brian 2019 年 4 月 10 日
コメント済み: Brian 2019 年 4 月 11 日
I'm trying to compute a simple sum of columns of a matrix. However, MATLAB is giving me ridiculously small answers and I don't know why.
The sum of this list of numbers is coming out as which I know is wrong (I've done it both by hand and through Excel) - it should be . Why is this the case?
  2 件のコメント
James Tursa
James Tursa 2019 年 4 月 11 日
編集済み: James Tursa 2019 年 4 月 11 日
Posting pictures of numbers is useless to your readers. Nobody is going to hand type in all of those values. Please delete that picture and post your numbers as actual text that we can copy and paste into MATLAB. Thanks. (And I am pretty sure MATLAB is calculating the sum correctly of the numbers it was given unless you are shadowing the sum function)
Brian
Brian 2019 年 4 月 11 日
I can't. The editor won't let me copy/paste for whatever reason.

サインインしてコメントする。

回答 (1 件)

James Tursa
James Tursa 2019 年 4 月 11 日
編集済み: James Tursa 2019 年 4 月 11 日
It could be you are comparing apples to oranges. The actual numbers probably have more than four digits that are not being displayed but do play a part in calculations (such as sum). If you hand type in those values or only copy the digits that are displayed, you might only expect agreement to the number of digits that are displayed, which is 4. Maybe that is why you see the difference at 10^-4.

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by