Finding Values in a file

5 views (last 30 days)
Chris Dan
Chris Dan on 23 Dec 2019
Commented: Walter Roberson on 24 Dec 2019
Hello, I have a file named as " model_data".
talha3.JPG
In the first column, there are different values from 0 to 0.1216. I want to develop a program in such a way that if a user enters a value of 0.1 The program should tell the user in which row/ or in between which rows the value lies of the first column.
  3 Comments
Chris Dan
Chris Dan on 24 Dec 2019
I tried this line
X = find (0.0751 == model_data( :,1));
it gives me the answer 3, but when I try 0.1, I donot get any answer, where as I should be getting 3 and 4, because in between them 0.1 lies
Walter Roberson
Walter Roberson on 24 Dec 2019
The == operator is a bit-for-bit exact comparison . Your table entry probably only displays as 0.0751 and is probably not 0.075100000000000000088817841970012523233890533447265625 exactly like a hard-coded 0.0751 is.

Sign in to comment.

Answers (1)

Chris Dan
Chris Dan on 24 Dec 2019
X = find (0.0751 > model_data( :,1));
Y = find (0.0751 <model_data( :,1));
I kind of got the answer, we get two variables and then we can choose their data values, which we want, like
Y(1,1),Y(2,1), Y(3,1)
X(1,1),X(2,1), X(3,1)
and that will be our answers

Categories

Find more on Structures in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!