Need help with homework (simple backwards interpolation)
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I want to calculate temperature of steam based on given enthalpy and pressure.
Example: https://imgur.com/a/u3rVOcD
The code should find temperature value (y axis) based on given enthalpy value (values in table) and pressure value (x axis). It is basically an backward interpolation, but with 2 variables.
Previously i have been using this code:
hnv_sek = 463.4
pk= 32
X_ZV = data_p_h(1,2:end)
Y_ZV = data_p_h(2:end,1)
Z_ZV = data_p_h(2:end,2:end)
x_ZV = pk
z_ZV = hnv_sek
fun_ZV = @(y_ZV)interp2(X_ZV,Y_ZV,Z_ZV,x_ZV,y_ZV)-z_ZV;
y_ZV = fzero(fun_ZV,mean(Y_ZV))
tnv_sek = y_ZV
interp2(X_ZV, Y_ZV, Z_ZV ,x_ZV , y_ZV)
end
And for values of data about and below 560, i have been getting this error (It was working fine with values that are high in table, until i get to low values. Any help would be greatly thanked for.):
Exiting fzero: aborting search for an interval containing a sign change
because NaN or Inf function value encountered during search.
(Function value at 37.0123 is NaN.)
Check function or try again with a different starting value.
0 commentaires
Réponses (1)
Torsten
le 20 Jan 2022
Specify the extrapolation value in interp2.
2 commentaires
Torsten
le 20 Jan 2022
If the requested data y_zv is not between min(Y_ZV) and max(Y_ZV), interp2 together with your interpolation method 'linear' returns NaN.
Therefore, you have to specify a value to be returned for the cases y_zv < min(Y_ZV) or y_zv > max(Y_ZV).
Look into the documentation for interp2 for more details.
Voir également
Catégories
En savoir plus sur Interpolation 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!