Clear Filters
Clear Filters

Using interp3 pull information from a table

1 view (last 30 days)
Hi all,
I am trying to use the interp3 funciton to find more accurate information from the table attached to this question. The idea is that you put in a known pressure altitude, rmp, and temperature, to yield %bhp, KTAS, and GHP values. For example I have written the following code to do so:
%Data
cruiseTable = [ 2000 2800 87 128 8.8 83 129 8.7 80 130 8.6;...
0 2700 78 123 7.7 74 124 6.8 72 125 6.6;...
0 2600 69 118 6.4 66 119 6.2 64 120 6.1;...
0 2500 61 113 5.9 59 113 5.7 57 114 5.6;...
0 2400 54 107 5.3 52 108 5.2 50 109 5.1;...
4000 2800 79 126 8.6 76 127 8.6 74 129 6.8;...
0 2700 71 121 6.6 68 122 6.4 66 123 6.2;...
0 2600 63 116 6 61 117 5.9 59 118 5.7;...
0 2500 56 111 5.5 55 112 5.4 53 113 5.3;...
0 2450 53 108 5.3 51 109 5.1 50 110 5.1;...
6000 2800 73 125 6.7 70 126 6.5 69 128 6.4;...
0 2700 66 120 6.2 64 121 6 62 123 5.9;...
0 2600 59 115 5.7 57 116 5.6 56 117 5.5;...
0 2500 53 110 5.2 51 111 5.1 50 112 5.0;...
8000 2800 68 124 6.4 66 125 6.2 65 127 6.1;...
0 2700 61 119 5.9 60 121 5.8 59 122 5.7;...
0 2600 55 114 5.4 54 116 5.3 53 117 5.3;...
0 2550 53 112 5.2 51 113 5.1 50 114 5.1;...
10000 2800 64 123 6.1 63 125 6 61 127 5.9;...
0 2750 61 121 5.9 60 123 5.8 59 124 5.7;...
0 2700 58 119 5.6 57 120 5.5 56 122 5.5;...
0 2650 55 116 5.4 54 118 5.3 53 119 5.3;...
0 2600 53 114 5.2 51 115 5.1 51 117 5.1;...
12000 2800 61 123 5.8 60 125 5.8 59 127 5.7;...
0 2750 58 121 5.6 57 123 5.6 56 124 5.5;...
0 2700 55 118 5.4 54 120 5.4 53 122 5.3;...
0 2650 53 116 5.2 52 118 5.2 51 119 5.1 ];
%Known (user input) values
%TAKE THIS OUT
pressAltFt = 2000;
rpm = 2800;
tempInC = 15;
if 2000 <= pressAltFt && pressAltFt < 4000
if 2700 < rpm && rpm <= 2800
xValues = [ -5 15 25 ]; %temp
yValues = [ 2800 2700 ]; %rmp
vValuesBHP = [ 80 83 87;... %bhp
78 74 72 ];
vValuesKTAS = [ 128 129 130;... %ktas
123 124 125 ];
vValuesGPH = [ 8.8 8.7 8.6;... %gph
7.7 6.8 6.6 ];
bhp = interp2( xValues, yValues, vValuesBHP, tempInC, rpm, 'linear')
ktas = interp2( xValues, yValues, vValuesKTAS, tempInC, rpm, 'linear')
gph = interp2( xValues, yValues, vValuesGPH, tempInC, rpm, 'linear')
end
end
As you can see I have used the interp2 function in this code. Using this works well for finding the bhp, ktas, and gph BUT it will theroretically only work at the pressure altutudes given by the table (2,000 4,000 6,000...). What I would also like to do is interpolate the data between pressure altitudes, so a pressure altitude such as 3,000 can be entered and accurate bph, ktas, and gph values can be given.
To do this I know I need to utilize the interp3 funciton, but I'm not sure how it needs to be structured.
Thanks for the help,
Aaron

Answers (1)

Star Strider
Star Strider on 31 Jul 2020
That is going to be an ambitious project! It might be easier to contact the airplane manufacturer to see if a set of equations exists that created those handbook tables. It would likely be straightforward to implement them in MATLAB.
The probllem is that for interp2 and most of the others to work, the matrix must have a specific structure (such as on created by the ndgrid function), and this table does not. There also does not appear to be any way to force it to.
Here is an approach that will likely work, for each temperature section of the table:
cruiseTable2 = cruiseTable; % Copy Original
cruiseTable2(cruiseTable2(:,1) == 0,1) = NaN; % Zeros Are ‘missing’
cruiseTable2(:,1) = fillmissing(cruiseTable2(:,1),'previous'); % Interpolate To Fill Table Column 1
standardTemp = [cruiseTable2(:,1:2), cruiseTable2(:,6:8)];
PA = 2800;
rpm = 2750;
PA_Lv = standardTemp(:,1)>=fix(PA/1000)*1000 & standardTemp(:,1)<fix((PA+2000)/1000)*1000; % Logical Vector
bhp_KTAS_GPH = interp1(standardTemp(PA_Lv,2), standardTemp(PA_Lv,3:end), rpm); % Interpolate To ‘rpm’ Value
It first fills in column #1, then uses a logical vector to interpolate on the ‘rpm’ value. Interpolating the temperatures would likely require a separate interpolation, so it would be necessary to do this on each section of the table, then interpolate the temperatures appropriately between the matrices created from the initial interpolations.
I do not have the Aerospace Toolbox, so I have no experience with it, however it may have a set of functions that would make this much easier.
  2 Comments
Aaron Staszewski
Aaron Staszewski on 3 Aug 2020
Thank you so much for your help! I would not have thought to make a logical vector and then interpolate accross it to read the table. Like you mentioned, this only gives the values at the three specific temperatures: 20 below standard, at standard, and 10 above standard.
To allow for a specific temperature to be entered (within the temperature range) I piggy backed off of the code you provided and came up with the following:
%Data
cruiseTable = [ 2000 2800 87 128 8.8 83 129 8.7 80 130 8.6;...
0 2700 78 123 7.7 74 124 6.8 72 125 6.6;...
0 2600 69 118 6.4 66 119 6.2 64 120 6.1;...
0 2500 61 113 5.9 59 113 5.7 57 114 5.6;...
0 2400 54 107 5.3 52 108 5.2 50 109 5.1;...
4000 2800 79 126 8.6 76 127 8.6 74 129 6.8;...
0 2700 71 121 6.6 68 122 6.4 66 123 6.2;...
0 2600 63 116 6 61 117 5.9 59 118 5.7;...
0 2500 56 111 5.5 55 112 5.4 53 113 5.3;...
0 2450 53 108 5.3 51 109 5.1 50 110 5.1;...
6000 2800 73 125 6.7 70 126 6.5 69 128 6.4;...
0 2700 66 120 6.2 64 121 6 62 123 5.9;...
0 2600 59 115 5.7 57 116 5.6 56 117 5.5;...
0 2500 53 110 5.2 51 111 5.1 50 112 5.0;...
8000 2800 68 124 6.4 66 125 6.2 65 127 6.1;...
0 2700 61 119 5.9 60 121 5.8 59 122 5.7;...
0 2600 55 114 5.4 54 116 5.3 53 117 5.3;...
0 2550 53 112 5.2 51 113 5.1 50 114 5.1;...
10000 2800 64 123 6.1 63 125 6 61 127 5.9;...
0 2750 61 121 5.9 60 123 5.8 59 124 5.7;...
0 2700 58 119 5.6 57 120 5.5 56 122 5.5;...
0 2650 55 116 5.4 54 118 5.3 53 119 5.3;...
0 2600 53 114 5.2 51 115 5.1 51 117 5.1;...
12000 2800 61 123 5.8 60 125 5.8 59 127 5.7;...
0 2750 58 121 5.6 57 123 5.6 56 124 5.5;...
0 2700 55 118 5.4 54 120 5.4 53 122 5.3;...
0 2650 53 116 5.2 52 118 5.2 51 119 5.1 ];
%Asking for input
% pressAlt = input('Pressure altitude in feet: ');
% rpm = input('RPM: ');
% tempInC = input('Temperature in celcius: ');
pressAlt = 2000;
rpm = 2800;
tempInC = 25;
cruiseTable2 = cruiseTable; % Copy Original
cruiseTable2(cruiseTable2(:,1) == 0,1) = NaN; % Zeros Are ‘missing’
cruiseTable2(:,1) = fillmissing(cruiseTable2(:,1),'previous'); % Interpolate To Fill Table Column 1
%Finding the bhp, KTAS, and GPH values at 20 below standard temperature
twentyBelowTemp = [cruiseTable2(:,1:2), cruiseTable2(:,3:5)];
PA_Lv_blw = twentyBelowTemp(:,1)>=fix(pressAlt/1000)*1000 & twentyBelowTemp(:,1)<fix((pressAlt+2000)/1000)*1000; % Logical Vector
bhp_KTAS_GPHatBelow = interp1(twentyBelowTemp(PA_Lv_blw,2), twentyBelowTemp(PA_Lv_blw,3:end), rpm); % Interpolate To ‘rpm’ Value
%Finding the bhp, KTAS, and GPH values at standard temperature
standardTemp = [cruiseTable2(:,1:2), cruiseTable2(:,6:8)];
PA_Lv_sta = standardTemp(:,1)>=fix(pressAlt/1000)*1000 & standardTemp(:,1)<fix((pressAlt+2000)/1000)*1000; % Logical Vector
bhp_KTAS_GPHatStandard = interp1(standardTemp(PA_Lv_sta,2), standardTemp(PA_Lv_sta,3:end), rpm); % Interpolate To ‘rpm’ Value
%Finding the bhp, KTAS, and GPH values at 10 above standard temperature
tenAboveTemp = [cruiseTable2(:,1:2), cruiseTable2(:,9:11)];
PA_Lv_abv = tenAboveTemp(:,1)>=fix(pressAlt/1000)*1000 & tenAboveTemp(:,1)<fix((pressAlt+2000)/1000)*1000; % Logical Vector
bhp_KTAS_GPHatAbove = interp1(tenAboveTemp(PA_Lv_abv,2), tenAboveTemp(PA_Lv_abv,3:end), rpm); % Interpolate To ‘rpm’ Value
%Defining the temperature range
tempRange = [ -5, 15, 25 ];
%Interpolating bhp at a given temperature
bhpRange = [ bhp_KTAS_GPHatBelow(1) bhp_KTAS_GPHatStandard(1) bhp_KTAS_GPHatAbove(1) ];
bhp = interp1(tempRange, bhpRange, tempInC);
%Interpolating KTAS at a given temperature
KTASRange = [ bhp_KTAS_GPHatBelow(2) bhp_KTAS_GPHatStandard(2) bhp_KTAS_GPHatAbove(2) ];
KTAS = interp1(tempRange, KTASRange, tempInC);
%Interpolating GPH at a given temperature
GPHRange = [ bhp_KTAS_GPHatBelow(3) bhp_KTAS_GPHatStandard(3) bhp_KTAS_GPHatAbove(3) ];
GPH = interp1(tempRange, GPHRange, tempInC);
allThree = [ bhp, KTAS, GPH ]
Essentially all it does is re-interpolate the already interpolated bhp, KTAS, and GPH values, but this time accross a temperature x coordinates, and at a given temperature. I'm sure this isn't the fastest or most efficient way to do this, but it seem to work for me.
I am now working on trying to get the data to interpolate past the temperature range. For example at 11 above standard temperature. (If anyone has any thoughts on this, some help would be appreciated)
Just posting this reply for anyone else looking to interpolate data from a similar, nontraditional chart. Thanks again for the help!
Star Strider
Star Strider on 3 Aug 2020
My pleasure!
I would not attempt to extrapolate, since it is likely not possible to produce the correct relationship between temperature and the other values beyond the region they are already calculated. I would certainly not use such extrapolated values to actually fly with, since they could be significantly at variance with reality.

Sign in to comment.

Categories

Find more on Interpolating Gridded Data 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!