I want to know the difference between 1 and 1.0000

9 ビュー (過去 30 日間)
neal paze
neal paze 2021 年 9 月 7 日
コメント済み: neal paze 2021 年 9 月 9 日
When I do logarithms, I run into some difficulties.
a=d3/f1;
b=log10(a);
c=10*log10(a);
d=1.0000;
d3=697.5512; f1=697.5512;
And the result is a=1.0000; and log10(a)=-9.643274665532978e-15
But if I type d=1.0000,the result is d=1; log10(d)=1

採用された回答

Abolfazl Chaman Motlagh
Abolfazl Chaman Motlagh 2021 年 9 月 7 日
編集済み: Abolfazl Chaman Motlagh 2021 年 9 月 7 日
first of all log10(1) should be zero!
but beside this,
i think you are reporting your workspace wich is produced after some calculation. and you thought the number you see is exactly what it is. the d3 and f1 might not be exactly what you see in workspace , it just show 4 decimal digits of them.
i am copying your code and run it here to see what i mean :
d3=697.5512;
f1=697.5512;
a=d3/f1;
log10(a)
ans = 0
you see it is correct but here i am resolving your result to see what i meant before :
format long
d3_ = f1 * (10^(-9.643274665532978e-15))
d3_ =
6.975511999999845e+02
so d3 and f1 are not exactly what is reported in user interface of workspace. for see them more precisely call
format long
and print them. (or use vpa function)

その他の回答 (1 件)

Jan
Jan 2021 年 9 月 7 日
編集済み: Jan 2021 年 9 月 7 日
The output is mimited to 4 digits after the decimal point. Then "1" means 1.0, and "1.0000" means that there is a digit differing from 0 hidden on the right.
Check this by:
a - 1 % Not 0
d - 1 % 0
e1 - 1 % Not 0

カテゴリ

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