Finding Values in a file

5 次查看(过去 30 天)
Chris Dan
Chris Dan 2019-12-23
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 个评论
Chris Dan
Chris Dan 2019-12-24
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 2019-12-24
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.

请先登录,再进行评论。

回答(1 个)

Chris Dan
Chris Dan 2019-12-24
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

类别

Help CenterFile Exchange 中查找有关 Structures 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by