Interpolation of values in a table?
조회 수: 3 (최근 30일)
이전 댓글 표시
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
M. A. Hopcroft
2016년 2월 11일
I don't see an attachment. Maybe you can just state your question? What do you mean by "calculate the nearest"?
답변 (1개)
Star Strider
2016년 2월 11일
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
Star Strider
2016년 2월 11일
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.
참고 항목
카테고리
Help Center 및 File Exchange에서 Preprocessing Data에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!