How can I interpolate lines and colonnes
2 次查看(过去 30 天)
显示 更早的评论
I have a table that I need to interpolate using two inputs. I want to be able to input weight and FL values and return an interpolated value from the table. I've attached a picture for clarification, any help would be awesome. Thanks.
0 个评论
回答(1 个)
Star Strider
2022-6-17
First, all four of those matrices would have to be entered separately.
Second, use ndgrid to create the matrices from the necessary vectors, and then use griddedInterpolant to do the actual interpolation. See the griddedInterpolant documentation for details.
Example —
From the lower left part of the table for the ‘TIME’ matrix —
FL = [15 50 100 120];
Wgt = 58:2:62;
TIME = [1 1 1; 2 2 2; 3 3 4; 4 4 5];
[FLm,Wgtm] = ndgrid(FL, Wgt);
TIMEi = griddedInterpolant(FLm,Wgtm,TIME);
FLq = 75;
Wgtq = 61;
TIME_75_61 = TIMEi(FLq,Wgtq)
figure
surf(FLm,Wgtm,TIME, 'FaceAlpha',0.75)
hold on
stem3(FLq, Wgtq, TIME_75_61, '^r', 'MarkerFaceColor','r')
hold off
grid on
xlabel('Flight Level')
ylabel('Weight (1000 kg)')
zlabel('Time (Min)')
So, under those conditions, for the airplane to reach Flight Level 75 (7500 feet assuming ISA conditions) with a Weight of 61 kg, it would take (using linear interpolation) about 2 min 45 sec.
.
2 个评论
Star Strider
2022-6-17
My pleasure!
‘I don't know how to interpolate if both of FL and weight values aren't in the table’
They have to be there. How the matrix and the interpolation is done depends on the the necessary variables being in the table. I demonstrated how to do that, so that FL and Weight refer to the other variables. The matrices themselves (I used TIME here) can be imported as such from Excel or whatever else they are stored in. Use ndgrid to create the FL and Weight matrices that griddedInterpolant can use for its interpolations.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!