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

6 vues (au cours des 30 derniers jours)
Isa Duran
Isa Duran le 11 Mar 2016
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

Réponse acceptée

Guillaume
Guillaume le 11 Mar 2016
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])

Plus de réponses (0)

Catégories

En savoir plus sur Interpolation dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by