필터 지우기
필터 지우기

interp1 problem

조회 수: 2 (최근 30일)
Hannah
Hannah 2011년 5월 7일
Hi, I am trying to use the interp1 function. I keep getting a NaN response. This is what I have tried:
EDU>> rho=[1.4133,1.3587,1.2614,1.1769,1.1032];
EDU>> T=[250,260,280,300,320];
EDU>> interp1(rho,T,275)
ans =
NaN
It is very simple, but I am trying to work my way up. Thank you

답변 (1개)

Teja Muppirala
Teja Muppirala 2011년 5월 7일
Are you trying to find the value of rho given that T=275?
rho=[1.4133,1.3587,1.2614,1.1769,1.1032];
T=[250,260,280,300,320];
interp1(T,rho,275)
  댓글 수: 2
Hannah
Hannah 2011년 5월 7일
Yes, I want to interpolate rho for a range of T from 275 - 320.
Teja Muppirala
Teja Muppirala 2011년 5월 7일
Then you can do:
Ti = 275:320;
rho_i = interp1(T,rho,Ti)
You basically had your rho and T backwards.
Your code:
interp1(rho,T,275)
computes "When rho is 275, what is T?"
You get a NaN because 275 is way outside the data for rho, and by default it does not extrapolate outside the original data range.

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by