필터 지우기
필터 지우기

How can I interpolate for " not strictly monotonic increasing vectors" ?

조회 수: 2 (최근 30일)
Isa Duran
Isa Duran 2016년 3월 11일
답변: Guillaume 2016년 3월 11일
Hi All! I have tried to do some interpolation lately but unfortunately I have some issues.
I have a speed array called
Speed = [22 22 22.5 22.5]
and I have a Angle array called
Angle = [130 180 130 180].
So I have run my script for those arrays and I have a output called RPM.
RPM = [91.1490 91.2120 93.2234 93.2860].
The way I have run my script is by "Crossing the inputs(Speed and Angle), so the first RPM (RPM(1)) is simply for Speed = 22 and Angle = 130, RPM(2) = speed = 22 Angle = 180 etc. I want to find the RPM for a given Speed and Angle in the range, lets say Speed = 22.3 and Angle = 150. When I use interp2 the error massage is "The grid vectors are not strictly monotonic increasing". How do I solve this problem? I hope the problem in understandable, otherwise feel free to ask!
Best regards Isa

채택된 답변

Guillaume
Guillaume 2016년 3월 11일
Use griddedinterpolant, if your known points are properly gridded, or scatteredinterpolant if not.
If your known points are properly gridded, you first need to convert them into a grid:
Speed = [22 22 22.5 22.5];
Angle = [130 180 130 180];
RPM = [91.1490 91.2120 93.2234 93.2860];
Speedgrid = reshape(Speed, [2 2]);
Anglegrid = reshape(Angle, [2 2]);
RPMgrid = reshape(RPM, [2 2]);
g = griddedInterpolant(Anglegrid, Speedgrid, RPMgrid); %Angle and speed need to be in this order, or the whole lot transposed
%query for speed = 25, angle = 150:
rpm25_150 = g([150, 25])
Using scattered interpolant:
s = scatteredInterpolant(Speed', Angle', RPM')
rpm25_150 = s([25, 150])

추가 답변 (0개)

카테고리

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