Using interp3 pull information from a table
조회 수: 1 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
답변 (1개)
Star Strider
2020년 7월 31일
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
Star Strider
2020년 8월 3일
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.
참고 항목
카테고리
Help Center 및 File Exchange에서 Interpolating Gridded Data에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!