Finding Values in a file

5 vues (au cours des 30 derniers jours)
Chris Dan
Chris Dan le 23 Déc 2019
Commenté : Walter Roberson le 24 Déc 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 commentaires
Chris Dan
Chris Dan le 24 Déc 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 le 24 Déc 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.

Connectez-vous pour commenter.

Réponses (1)

Chris Dan
Chris Dan le 24 Déc 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

Catégories

En savoir plus sur Structures dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by