필터 지우기
필터 지우기

How can I check which values in 2 matrices are identical?

조회 수: 1 (최근 30일)
Bianca Elena Ivanof
Bianca Elena Ivanof 2017년 3월 29일
댓글: Jan 2017년 3월 29일
Dear all,
I have 2 matrices (attached) - as their name suggests, the 1st contains mean values while the 2nd contains trimmed means values. I am interested in finding out which means and trimmed means differ (upon eyeballing both arrays, lots of values seem identical, which makes sense to me since I'm trimming my data only ever so slightly). In order to do this, I've done this:
difference= means_IB-trimmean_IB;
distinction= find (d~=0);
However, upon eyeballing the difference matrix, I can't explain some values - for example,
means_IB(3,2)
ans =
-32.2740
trimmean_IB(3,2)
ans =
-32.2740
difference(3,2)
ans =
-1.4211e-14
I have a slight hunch the result of difference(3,2) has to do with decimal places not captured by the matrices but I don't think my intuition is right.
Would you please be so kind as to help me?
Thank you in advance, Bianca
  댓글 수: 3
Bianca Elena Ivanof
Bianca Elena Ivanof 2017년 3월 29일
I am interested in finding out which means and trimmed means differ (which implies the explanation for the -1.42e-14 value).
Jan
Jan 2017년 3월 29일
You did not show yet, how this value is created. All we know, is that you got it from some calculations.

댓글을 달려면 로그인하십시오.

답변 (1개)

Jan
Jan 2017년 3월 29일
편집: Jan 2017년 3월 29일
means_IB(3,2) - trimmean_IB(3,2)
% >> -1.4211e-14
This means, that this is the distance between the two values. An explanation of this effect would concern the calculation of trimmean_IB, but without seeing the corresponding code, it is hard to guess the details.
Most likely the routine for the trimming leads to different rounding "errors", which are not errors, but the effect of storing values in the double format with a limited precision. According to the "IEEE754 standard" doubles contain about 16 digits. In consequence arithmetic operations can differ by eps (see: doc eps) according to the order of the operations:
1 + 1e-17 - 1
1 - 1 + 1e-17
You can control (but not solve!) this by using a tolerance:
distinction= find(d > 10 * eps(means_IB));
The used limit depends on the problem.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by