Matrix division not returning enough decimal places

I am trying to complete a school project using R2018a but I can't get my intermediate values (Eq1x) accurate enough to accurately use polyfit.
format long
T = [196.85, 206.85, 216.85, 226.85, 236.85];
T = T + 273.15; %converts T from celcius to K %T = [470, 480, 490, 500, 510]
Eq1x = (1./T); %inverse of the temperture in K
format long
When I run this, variable Eq1x returns [0.0021, 0.0021, 0.0020, 0.0020, 0.0020].
When I plug these into my TI calculator, I get [0.0021277, 0.0020833, 0.0020408, 0.002000, 0.0019607]
How can I get matlab to return values similar to my calculator values?

2 件のコメント

jessupj
jessupj 2020 年 4 月 29 日
try 'format long g'
Mitchell Belz
Mitchell Belz 2020 年 4 月 29 日
I just tried that, but it was still returning the rounded values

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

 採用された回答

Ameer Hamza
Ameer Hamza 2020 年 4 月 29 日

0 投票

I guess you are looking at the variable value in Variable browser window. 'format long' applies to the command window. Run your code and then run following line in the command window
Eq1x
without semicolon.

5 件のコメント

Mitchell Belz
Mitchell Belz 2020 年 4 月 29 日
That worked! thank you!
Will the values shown in the command window be the ones used in the caluclations?
Ameer Hamza
Ameer Hamza 2020 年 4 月 29 日
編集済み: Ameer Hamza 2020 年 4 月 29 日
I am glad to be of help.
Yes, internally, they are stored like that. You can even see these values in the variable browser window by double-clicking the cells.
jessupj
jessupj 2020 年 4 月 29 日
why assume op is looking at the value in the browser window after op states matlab is 'returning the rounded values'?
Mitchell Belz
Mitchell Belz 2020 年 4 月 29 日
Thank you both. before i used format long g I couldnt even see the full values in the cells of the variable.
Ameer Hamza
Ameer Hamza 2020 年 4 月 29 日
I just guessed based on the description. After running format long, the command window will be displaying 15 digits after decimal point (unless there are some serious issues with MATLAB installation). So the only explanation was that the OP was looking at the variable browser window, which displays four digits by default.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeResizing and Reshaping Matrices についてさらに検索

製品

リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by