MATLAB: How to write a function to find a value from a table.

aerospacefunctioninterpolationspecific heattable

I have a table that looks like this https://www.ohio.edu/mechanical/thermo/property_tables/air/air_Cp_Cv.html. I need to write a function with temperature as the input and the other three points of data as the output, but I am unsure of how to set up the code? How do I write a code that also interpolates if the temperature value is between two points of known data? I am very very new to matlab and am not at all sure how to even start. Any help would be greatly appreciated. Thank you in advance!

Best Answer

I would use the interp1 function.
You can easily make a function from it:
M = [ 250 1.003 0.716 1.401
300 1.005 0.718 1.400
350 1.008 0.721 1.398
400 1.013 0.726 1.395];
CpCvk = @(TK) interp1(M(:,1), M(:,2:4), TK, 'linear', 'extrap');
T325 = CpCvk(325)
T325 =
1.0065 0.7195 1.399