How can I interpolate lines and colonnes

2 Ansichten (letzte 30 Tage)
Simou
Simou am 17 Jun. 2022
Kommentiert: Star Strider am 17 Jun. 2022
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.

Antworten (1)

Star Strider
Star Strider am 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)
TIME_75_61 = 2.7500
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 Kommentare
Simou
Simou am 17 Jun. 2022
Thank you very much for the explication. I forgot to mention that I'm going to create an app to calculate necessary time and fuel for all parts of flight, so I have more of these tables and all matrices are necessary. I think that creating separate tables from the previous table in Excel (table of time, distance...) and importing them to Matlab would be easier, but I don't know how to interpolate if both of FL and weight values aren't in the table.
Star Strider
Star Strider am 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.

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by