interp1 problem

3 views (last 30 days)
Hannah on 7 May 2011
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 =
It is very simple, but I am trying to work my way up. Thank you

Answers (1)

Teja Muppirala
Teja Muppirala on 7 May 2011
Are you trying to find the value of rho given that T=275?
Teja Muppirala
Teja Muppirala on 7 May 2011
Then you can do:
Ti = 275:320;
rho_i = interp1(T,rho,Ti)
You basically had your rho and T backwards.
Your code:
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.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by