I need to set up a library
2 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Walter Roberson
2018 年 10 月 13 日
... However, for something with only two possible options, just coding your own parsing might be easier.
2 件のコメント
Walter Roberson
2018 年 10 月 13 日
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.
参考
カテゴリ
Help Center および File Exchange で Thermodynamics and Heat Transfer についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!