how to find the equality of 2 numbers?

a e
1 1
1 2
3 2
3 2
The above is my input table. Check 'a' for the value '1'. The corresponding 'e' value differs. So, we should not consider it. Check 'a' the value of '3'. The corresponding 'e' values are same. How to develop code for this?

댓글 수: 5

Azzi Abdelmalek
Azzi Abdelmalek 2012년 9월 10일
your data are what? string?,double?
Image Analyst
Image Analyst 2012년 9월 10일
I think a and e are the column headers, so the variables named a and e are integers, but they may be of class int32, uint8, uint16, or even single or double.
Yes. As Image Analyst told, 'a' and 'e' are column headers... There is no '' strings'' in my input values
Image Analyst
Image Analyst 2012년 9월 10일
Then see my answer. Also, what does "class(a)" show when you issue that command? If you want to make absolutely sure a and e are integers, wrap them in an int32() when you create them.

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

 채택된 답변

Andrei Bobrov
Andrei Bobrov 2012년 9월 10일

1 개 추천

AE = [a e]; %The initial array
out = AE(abs(diff(AE,1,2)) < eps(100),:);

댓글 수: 1

Hi Andrei,Thanks. Your answer matches my requirement 90%.. for no.'2' your code works fine. Since there is a deviation in '1' it should not come. You can see the change in the value of 'e' when the value of 'a' is 1. Can you modify the code

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

추가 답변 (3개)

Adrian Dronca
Adrian Dronca 2012년 9월 10일

0 개 추천

I think you should consider using isequal() . The function works with single, double, string.
Image Analyst
Image Analyst 2012년 9월 10일

0 개 추천

If they're integers, use ==, like
if a == e
if they're floating point, you need to check against a tolerance:
if abs(a-e) < 0.0001
Sivakumaran Chandrasekaran
Sivakumaran Chandrasekaran 2012년 9월 12일

0 개 추천

When you go through the first two rows, you can find that the change in the values. So, '1' should be omitted. There is no change in 3rd and 4th row.. 'e' value does not gets changed. So, we can consider 'e' .
How to do this??

카테고리

도움말 센터File Exchange에서 Performance and Memory에 대해 자세히 알아보기

제품

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by