Lookup Table the floor value
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I´m a new user of Matlab and I´m trying to get the y floor value of a table. I´ve looking for it and the interpn1 command only let you to get the nearest value not the floor.
An example is for the table:
1 10
10 30
If I ask for the value of 9, I need to get 10 (if I use interpn1 nearest I get 30).
Thanks in advance
0 commentaires
Réponse acceptée
Mike Hosea
le 12 Avr 2011
For a table x,y with x sorted ascending, you can do a linear time lookup for the value xi in the "floor" sense via
y(find(xi>=x,1,'last'))
-- Mike
0 commentaires
Plus de réponses (4)
the cyclist
le 12 Avr 2011
If A is your array, I think you want something like:
y_floor = min(A(A>9))
0 commentaires
Andrei Bobrov
le 12 Avr 2011
added variant
A = randi(120,5,5)
n = 9
[~,I] = min(abs(A(:)-n));
A(I)
0 commentaires
Walter Roberson
le 12 Avr 2011
Use the two output form of histc() to get the bin numbers, and use the bin numbers to index the y table.
0 commentaires
Voir également
Catégories
En savoir plus sur Tables dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!