Interpolation of values in a table?
4 views (last 30 days)
Show older comments
Im trying to follow along with the directions in the attachment, and I got a table made which is T. AA_tire_degree1 is the values shown in table 2 of the pdf. I cant figure out how to get the nearest value, and the spline estimates for the table in the pdf. I've got code to calculate the nearest, but im not sure it is correct. Any help would be greatly appreciated.
clear all
tire=xlsread('tire_lab')
a=floor(linspace(22,222,10))
for k=1:10
AA_tire_degree(k)=tire(a(k),1);
deflection_mm(k)=tire(a(k),2);
end
AA_tire_degree=[-9.9000;-7.7000;-5.5000;-3.3000;-1.1000;1.2000;3.4000;5.6000;7.8000;10.1000]
deflection_mm=[138.0000;129.0000;109.0000;65.0000;24.0000;13.0000;24.0000;85.0000;173.0000;261.0100]
T=table(AA_tire_degree,deflection_mm)
% PercentError = abs(deflection_mm-deflection_mm(k))/deflection_mm*100
AA_tire_degree=[-9.9000;-7.7000;-5.5000;-3.3000;-1.1000;1.2000;3.4000;5.6000;7.8000;10.1000]
AA_tire_degree1=[-9.7; -6.7; 0.2; 4.3; 9.5]
Nearest=(interp1(AA_tire_degree,AA_tire_degree1,'nearest'))
3 Comments
M. A. Hopcroft
on 11 Feb 2016
I don't see an attachment. Maybe you can just state your question? What do you mean by "calculate the nearest"?
Answers (1)
Star Strider
on 11 Feb 2016
If you are allowed to use the interp1 function, see the documentation for it. It will do everything you need to do.
This assignment seems to be missing an argument:
Nearest=(interp1(AA_tire_degree,AA_tire_degree1,'nearest'));
what value of the independent variable do you want to interpolate to get the value you want?
2 Comments
Star Strider
on 11 Feb 2016
It looks correct to me.
If you got NaN values, it means you’re wanting to extrapolate. You have to tell interp1 that. The interp1 calls would then include the 'extrap' flag.
For example:
d_int_nearest = interp1(AA_tire_degree,deflection_mm,AA_tire_degree_int,'nearest','extrap')
and so for the others. That should eliminate the NaN elements.
See Also
Categories
Find more on Spline Postprocessing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!