How can I interpolate lines and colonnes
조회 수: 1 (최근 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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1035770/20220617_113911.jpg)
댓글 수: 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!