How to show nearest value of a separate function with known x and y inputs
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I'm developing a code for psychrometric graph and I'm looking for a way to find the nearest value of a function for a given x and y input. The graph works fine, but I'm beginning to develope user state points and processes for different conditions.
For the graph, 10 intervals for RH were created from 0-100% (I plan to make 1000 intervals, but lets keep it simple for the given question) . I nested another for loop for Tdb (x-axis) for the temperature range under consideration. From there, I solved for humidity ratio, w (y-axis), as a function of RH and Tdb. I would then plot Tdb vs. w for every interval of RH, yielding the "relative humidity" curves with respect to Tdb and w. (i.e. if RH=10, a line would plot for x vs y where RH=10. it did this from 0:0.1:100, only plotting multiples of 10.
I tried to solve the equation for RH from w, but it creates unnecessary complexities and errors that I cannot reconcile. Thus, I would prefer to be able to determine the nearest of the 10 RH intervals to my state point (Tdb,w). Can you find the nearest line to a point like that? Any help would be appreciated.
0 commentaires
Réponses (1)
Star Strider
le 10 Oct 2019
It seems to me that you are attempting to invert your data, that is calculating an ‘x’ value from a ‘y’ value. The easiest way to do that is likely the interp1 function. Note that you can select 'nearest', 'previous', and 'next' for the interpolation method.
0 commentaires
Voir également
Catégories
En savoir plus sur 2-D and 3-D Plots 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!