필터 지우기
필터 지우기

why eq says they are not equal

조회 수: 1 (최근 30일)
Nuchto
Nuchto 2012년 7월 19일
I have two equal vectors a = b. When I check for equality:
y = eq(a, b)
find(y==0)
I get most of values, meaning they are NOT equal.
What would be the reason for this?
N.
  댓글 수: 5
Nuchto
Nuchto 2012년 7월 22일
Thanks, I did.
Jan
Jan 2012년 7월 22일
@Nuchto: Is your problem solved?

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

채택된 답변

Muruganandham Subramanian
Muruganandham Subramanian 2012년 7월 19일
편집: Walter Roberson 2012년 7월 22일
Hi Nuchto,
Check this below link:
  댓글 수: 1
Nuchto
Nuchto 2012년 7월 19일
I have checked the help, but it didn't answer to my question.

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

추가 답변 (2개)

Jan
Jan 2012년 7월 19일
편집: Jan 2012년 7월 19일
To compare two vectors use:
r = isequal(a, b)
or to find the difference between vectors (or other arrays) of the same size:
any(a - b)
Note, that the later replies FALSE even for ones(1,10) and ones(1,1).
If you only assume, that the vectors have equal values, check a - b and note, that the limited precision of the type double leads to effects like:
03. - 0.2 ~= 0.1
Then check "almost equal" by:
limit = eps(max(max(abs(a(:)), abs(b(:)))));
% or: eps(max(abs(a(:)), abs(b(:))));
% or: the same times 10
a_eq_b = isequal(size(a), size(b)) & all(abs(a - b) < limit);
The choise of the limit depends on the physical meaning of the variables. There is no unique definition to distinguish measurement noise from noise caused by numerical artifacts for a tiny values.

Walter Roberson
Walter Roberson 2012년 7월 19일

카테고리

Help CenterFile Exchange에서 Digital Filter Analysis에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by