Interpolation from a table by using two variables

28 次查看(过去 30 天)
Hello i have a slight problem and it is kinda urgent to be honest. I can be considered as a noobie in MATLAB so i ask for forgiveness.
I am working on a rocket trajectory simulation project and i have a dataset acquired from CFD analysis for sea level altitudes of 0,3000,6000 meters and Mach number from 0 to 2.0 by step of 0.1. I created a loop by creating a time array and i can get previous results of Mach and altitude work in the next step, altough my problem is that i want to be able to get value of cd for ie. M=0.25 and h=1230 m in the loop, so far my advances are halted.
Here is the dataset in question, and i am dropping the .csv file if you feel use of.
NaN 0 3000 6000
0 0 0 0
0.1 0.4340 0.45120 0.47110
0.2 0.39540 0.40990 0.42670
0.3 0.37520 0.38850 0.40360
0.4 0.36170 0.37410 0.38820
0.5 0.35150 0.36330 0.37670
0.6 0.34290 0.35420 0.3670
0.7 0.33590 0.34680 0.35920
0.8 0.33090 0.34150 0.35360
0.9 0.32930 0.33980 0.35190
1 0.370 0.38050 0.39240
1.1 0.41110 0.42050 0.43130
1.2 0.39960 0.40830 0.41810
1.3 0.39950 0.40790 0.41750
1.4 0.39080 0.3990 0.40830
1.5 0.3820 0.390 0.39910
1.6 0.36960 0.37730 0.38620
1.7 0.35750 0.36510 0.37380
1.8 0.34610 0.35350 0.3620
1.9 0.3350 0.34230 0.35060
2 0.32440 0.33150 0.33960
So far i had some unsuccesfull attempts by using interp2 as i really could not undersand and use it. Sadly i do not have any meaningful code to show here.

采纳的回答

Walter Roberson
Walter Roberson 2022-5-3
data = [
NaN 0 3000 6000
0 0 0 0
0.1 0.4340 0.45120 0.47110
0.2 0.39540 0.40990 0.42670
0.3 0.37520 0.38850 0.40360
0.4 0.36170 0.37410 0.38820];
M = data(2:end,1);
h = data(1,2:end);
cd = data(2:end,2:end);
hq = 1230;
Mq = 0.25;
whos
Name Size Bytes Class Attributes M 5x1 40 double Mq 1x1 8 double cd 5x3 120 double cmdout 1x33 66 char data 6x4 192 double h 1x3 24 double hq 1x1 8 double
cdq = interp2(h, M, cd, hq, Mq)
cdq = 0.3910
  3 个评论

请先登录,再进行评论。

更多回答(1 个)

Torsten
Torsten 2022-5-3
X = 0:3000:6000;
Y = 0:0.1:2;
Z = [0 0 0
0.4340 0.45120 0.47110
0.39540 0.40990 0.42670
0.37520 0.38850 0.40360
0.36170 0.37410 0.38820
0.35150 0.36330 0.37670
0.34290 0.35420 0.3670
0.33590 0.34680 0.35920
0.33090 0.34150 0.35360
0.32930 0.33980 0.35190
0.370 0.38050 0.39240
0.41110 0.42050 0.43130
0.39960 0.40830 0.41810
0.39950 0.40790 0.41750
0.39080 0.3990 0.40830
0.3820 0.390 0.39910
0.36960 0.37730 0.38620
0.35750 0.36510 0.37380
0.34610 0.35350 0.3620
0.3350 0.34230 0.35060
0.32440 0.33150 0.33960];
Xq = 2000;
Yq = 0.55;
Zq = interp2(X,Y,Z,Xq,Yq)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

产品


版本

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by