Division problems wiht matrix, calculation error

2 ビュー (過去 30 日間)
Eduardo Ribeiro
Eduardo Ribeiro 2019 年 5 月 16 日
コメント済み: Eduardo Ribeiro 2019 年 5 月 17 日
Hello everyone!
I need some help to understand my problem.
In this piece of code:
LineInf=[Deforma(MinL-1,1) Tensao(MinL-1,1)]
LineSup=[Deforma(MaxL,1) Tensao(MaxL,1)]
MY= (LineInf(1,2)-LineSup(1,2))/(LineInf(1,1)-LineSup(1,1))
The results:
LineInf = 0.0021 119.9498
LineSup = 0.0046 220.1019
the final results should be:
MY=-100.1521/-0.0025 = 4.0061e+04
But instead the matlab gives me MY=3.9845e+04
My suspicion is that internally matlab calculates differently, due to the fact that they are matrix calculations.
My question is: is there any way around this and get the correct value? or even a command that I do not know.
Best regards
Ed

採用された回答

David Goodmanson
David Goodmanson 2019 年 5 月 16 日
編集済み: David Goodmanson 2019 年 5 月 17 日
Hi Eduardo,
It's quite likely that two of the displayed values for LineInf and LineSup are not what you think they are. The values .0021 and .0046 are displayed to two only significant figures, and if you look more closely at each of those individually, with extra significant figures their difference is not going to be exactly .0025. (you can look at the elements individually or use the statement 'format long g' before displaying the vectors LineInf and LineSup).
The .0025 only has to change to 0.00251354 in order to get everything to agree.
  1 件のコメント
Eduardo Ribeiro
Eduardo Ribeiro 2019 年 5 月 17 日
After your answer, I put it in a long format, and it really hits it right. I was deduced in error because of this, and was doing the calculation using a calculator, with abbreviated number..
Thanks David!

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by