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 Center および File ExchangeInterpolation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by