How is it possible that I get different answers for the same equations in two codes?

1 view (last 30 days)
I am writing a code for the thermomechanical behaviour of an one-dimensional element.
From line 146-150 in the first code (Transient_ThermomechanicalCoupling) i expect an answer for TRAC which is not zero. However the answer is zero. In the other code (VERGELIJKINGTRAC) i have the same variables and get an answer that is not zero. I can't find the problem and have been looking for it for days now... It might be a small error but i can't find it. I hope someone could help me.

Accepted Answer

Image Analyst
Image Analyst on 3 May 2015
They're totally different programs.
Anyway, perhaps you haven't read the FAQ: http://matlab.wikia.com/wiki/FAQ#Why_is_0.3_-_0.2_-_0.1_.28or_similar.29_not_equal_to_zero.3F - maybe it's a precision issue.
  4 Comments
Rick Titulaer
Rick Titulaer on 3 May 2015
In the first m-file (Transient_ThermomechanicalCoupling) the K matrix is calculated in line 72-98. Then the UT is calculated with line 146. Then i directly copied with control-c and control-v the matrix K and vector UT into the other m-file (VERGELIJKINGTRAC). THen when i calculate the TRAC in VERGELIJKINGTRAC i get values for all the five nodes. When i calculate the TRAC in Transient_ThermomechanicaCoupling i only get one value for the second node and 4 nodes zero.
I think it is strange because i use the same matrix and vector?
Rick Titulaer
Rick Titulaer on 3 May 2015
The UT vector i calculate with the first m-file (Transient_ThermomechanicalCoupling) is
7.71262898705694e-06 1.53556097935277e-05 6.34013739884418e-06 -5.21137363050607e-06 -7.71260858096823e-06 293.031375121031 293.026829323982 292.861307169013 293.527944249668
And the K matrix is:
1.50769066666667 -0.753845333333333 0 0 0 -1.15500000000000e-05 1.15500000000000e-05 0 0 -0.753845333333333 0.753845333333333 -0.753845333333333 0.0942306666666667 0 -2.88750000000000e-06 0 2.88750000000000e-06 0 0 -0.753845333333333 1.50769066666667 -0.753845333333333 0 0 -1.15500000000000e-05 1.15500000000000e-05 0 0 0.0942306666666667 -0.753845333333333 0.753845333333333 -0.753845333333333 0 -2.88750000000000e-06 0 2.88750000000000e-06 0 0 0 -0.753845333333333 1.50769066666667 0 0 -1.15500000000000e-05 1.15500000000000e-05 0 0 0 0 0 0.00675266666666667 -8.60000000000000e-05 0 0 0 0 0 0 0 -8.60000000000000e-05 0.000172000000000000 -8.60000000000000e-05 0 0 0 0 0 0 0 -8.60000000000000e-05 0.000172000000000000 -8.60000000000000e-05 0 0 0 0 0 0 0 -8.60000000000000e-05 0.0167526666666667
These values i copied to the other m-file and calculate it. But the answers are different.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!