Need help with homework (simple backwards interpolation)

조회 수: 2 (최근 30일)
Stefan Bogdanovic
Stefan Bogdanovic 2022년 1월 20일
댓글: Torsten 2022년 1월 20일
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.

답변 (1개)

Torsten
Torsten 2022년 1월 20일
Specify the extrapolation value in interp2.
  댓글 수: 2
Stefan Bogdanovic
Stefan Bogdanovic 2022년 1월 20일
Can you please define it more precisely? What do you mean by extrapolation value?
Torsten
Torsten 2022년 1월 20일
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

태그

제품


릴리스

R2015a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by