필터 지우기
필터 지우기

checking excel cell values using matlab

조회 수: 2 (최근 30일)
Dhandapani.S
Dhandapani.S 2017년 3월 9일
댓글: Image Analyst 2017년 3월 11일
hai i am Dhandapani. i used the following code to check the excel value. it should say true because the exact value in the partucular cell is '0.43916'. i even used xlsread to find . it displayed '0.4392'. i even changed the search valueto '0.4392' but the answer is 'no'. but when i checked for whole numbers like '45' it says 'yes'. kindly help in this regard. the code is as follows. after this i have to check for 5 cell values of excel for a pattern match. is this possible in matlab? Thanks in advance if xlsread('realsys1.xls', 'Sheet1', 'a1:a1') == 0.43916 display 'yes' else display 'no' end
  댓글 수: 2
kowshik Thopalli
kowshik Thopalli 2017년 3월 10일
This looks like a format problem. Use
format long
Will that solve your problem. The general recommendation to check float numbers a1 and a2 is that to not use directly a1==a2 but to use
abs(a1-a2)<epsilon.
where epsilon is a very small value like 0.001 or something similar.
Image Analyst
Image Analyst 2017년 3월 10일
Make this an answer below, in the answer section along with the other answers, not a comment.

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

답변 (1개)

Image Analyst
Image Analyst 2017년 3월 10일
Not surprising. It won't be to you either, after you 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
  댓글 수: 3
Dhandapani.S
Dhandapani.S 2017년 3월 11일
to be clear, i need to get a number(say 23.5444)as input using matlab and find in which row of an excel file, the number exists.
Image Analyst
Image Analyst 2017년 3월 11일
Did you try the code in the FAQ I referred you to? See where it says to look within a tolerance? If you have a new version of MATLAB, you can use ismembertol().

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

카테고리

Help CenterFile Exchange에서 Data Import from MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by