How can I interpolate lines and colonnes
4 views (last 30 days)
Show older comments
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1035770/20220617_113911.jpg)
0 Comments
Answers (1)
Star Strider
on 17 Jun 2022
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 Comments
Star Strider
on 17 Jun 2022
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.
See Also
Categories
Find more on Interpolation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!