I need to set up a library
3 views (last 30 days)
Show older comments
I am doing some thermodynamics things, and I would like to have a function that when given either two of temperature pressure or specific volume will interpolate for the other intensive property from the 100x3 matrix I have entered into the matlab function code. How could I create the logic for accepting 2 of the three input variables? I think I could figure out the interpolation part myself. Thank you so much!
0 Comments
Answers (1)
Walter Roberson
on 13 Oct 2018
... However, for something with only two possible options, just coding your own parsing might be easier.
2 Comments
Walter Roberson
on 13 Oct 2018
If you have a 100x3 matrix whose columns are temperature, pressure, and volume, then you do not have a regular grid of data, and more complicated (slower) interpolation methods must be used.
The general method is to use (for example)
first_var_col = 2;
second_var_col = 3;
resulting_var_col = 1;
first_var_value = ... %input value for first variable
second_var_value = ... %input value for second variable
estimated_result = griddata( YourData(:, first_var_col), YourData(:, second_var_col), YourData(:, resulting_var_col), first_var_value, second_var_value );
This will be a comparatively expensive operation. If you were potentially going to do multiple queries, then it would be a little more efficient to instead use scatteredInterpolant() and save the resulting object, and then next time you got the same kind of query, pull back the saved object instead of building a new scatteredInterpolant.
If it happened that your data could be arranged in a 10 x 10 regular grid, then faster querying could be done in one of the cases... but only one.
See Also
Categories
Find more on Thermodynamics and Heat Transfer 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!