Trying to create a polynomial using data from a table

Hi, i have some data for a valve which i try to create a polynomial based on two variable. i looked through multiple topics and came up with the below arrangement. I struggle to find an answer why the polynomial wouldn't give an accurate result after all. any guidance is much appreciated. Thanks
% Data preparation
dP = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35];
PressureInlet = [42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72];
values = [
0.02568, 0.03147, 0.03633, 0.04062, 0.0445, 0.04807, 0.05138, 0.05451, 0.05745, 0.06026, 0.06292, 0.06549, 0.06797, 0.07036, 0.07267, 0.0749, 0.07708, 0.07918, 0.08124, 0.08325, 0.08521, 0.08713, 0.08899, 0.09083, 0.09264, 0.09439, 0.09613, 0.09782, 0.0995, 0.1012, 0.1028, 0.1044, 0.1059, 0.1075;
0.02579, 0.03159, 0.03647, 0.04078, 0.04466, 0.04825, 0.05157, 0.0547, 0.05766, 0.06048, 0.06316, 0.06574, 0.06823, 0.07062, 0.07294, 0.07519, 0.07737, 0.07949, 0.08155, 0.08355, 0.08553, 0.08745, 0.08933, 0.09116, 0.09298, 0.09475, 0.09648, 0.09819, 0.09986, 0.1015, 0.1031, 0.1048, 0.1063, 0.1079;
0.02588, 0.03171, 0.0366, 0.04092, 0.04483, 0.04843, 0.05178, 0.05491, 0.05788, 0.06071, 0.0634, 0.06599, 0.06849, 0.07089, 0.07322, 0.07546, 0.07766, 0.07977, 0.08186, 0.08387, 0.08584, 0.08778, 0.08968, 0.09151, 0.09332, 0.0951, 0.09686, 0.09857, 0.1003, 0.1019, 0.1035, 0.1052, 0.1067, 0.1083;
0.02598, 0.03183, 0.03675, 0.04108, 0.045, 0.04862, 0.05198, 0.05511, 0.0581, 0.06095, 0.06365, 0.06624, 0.06875, 0.07116, 0.0735, 0.07575, 0.07796, 0.08009, 0.08216, 0.08421, 0.08618, 0.08812, 0.09002, 0.09187, 0.09368, 0.09547, 0.09722, 0.09894, 0.1006, 0.1023, 0.1039, 0.1055, 0.1071, 0.1087;
0.02608, 0.03195, 0.03689, 0.04125, 0.04519, 0.04881, 0.05218, 0.05534, 0.05832, 0.06117, 0.0639, 0.0665, 0.06902, 0.07143, 0.07377, 0.07606, 0.07826, 0.08041, 0.0825, 0.08453, 0.08651, 0.08846, 0.09036, 0.09223, 0.09406, 0.09584, 0.0976, 0.09933, 0.101, 0.1027, 0.1043, 0.106, 0.1076, 0.1091;
0.02619, 0.03208, 0.03703, 0.04141, 0.04535, 0.04898, 0.05238, 0.05555, 0.05855, 0.06141, 0.06414, 0.06677, 0.0693, 0.07173, 0.07408, 0.07636, 0.07856, 0.08072, 0.08282, 0.08487, 0.08686, 0.08881, 0.09071, 0.09259, 0.09443, 0.09623, 0.09799, 0.09972, 0.1014, 0.1031, 0.1048, 0.1064, 0.108, 0.1096;
0.02629, 0.03219, 0.03719, 0.04157, 0.04554, 0.04919, 0.0526, 0.05577, 0.05879, 0.06167, 0.06441, 0.06703, 0.06956, 0.072, 0.07437, 0.07665, 0.07887, 0.08105, 0.08314, 0.0852, 0.08722, 0.08916, 0.09109, 0.09296, 0.09481, 0.0966, 0.09837, 0.1001, 0.1018, 0.1035, 0.1052, 0.1068, 0.1084, 0.11;
0.02639, 0.03233, 0.03734, 0.04174, 0.04573, 0.0494, 0.0528, 0.056, 0.05904, 0.06192, 0.06467, 0.0673, 0.06986, 0.0723, 0.07467, 0.07698, 0.07922, 0.08137, 0.0835, 0.08554, 0.08757, 0.08954, 0.09145, 0.09333, 0.09518, 0.097, 0.09879, 0.1005, 0.1022, 0.1039, 0.1056, 0.1073, 0.1089, 0.1105;
0.0265, 0.03248, 0.0375, 0.04191, 0.04591, 0.0496, 0.05303, 0.05623, 0.05928, 0.06217, 0.06494, 0.06758, 0.07015, 0.0726, 0.07499, 0.0773, 0.07953, 0.08172, 0.08384, 0.0859, 0.08792, 0.0899, 0.09184, 0.09373, 0.09558, 0.09742, 0.09921, 0.1009, 0.1027, 0.1044, 0.1061, 0.1077, 0.1093, 0.1109;
0.02662, 0.03261, 0.03764, 0.0421, 0.04612, 0.04981, 0.05325, 0.05648, 0.05953, 0.06244, 0.06523, 0.06788, 0.07045, 0.0729, 0.0753, 0.07763, 0.07989, 0.08207, 0.08419, 0.08628, 0.08829, 0.09028, 0.09223, 0.09412, 0.096, 0.09782, 0.09963, 0.1014, 0.1031, 0.1048, 0.1065, 0.1082, 0.1098, 0.1114;
0.02674, 0.03275, 0.03782, 0.04229, 0.04633, 0.05003, 0.05349, 0.05672, 0.0598, 0.0627, 0.0655, 0.06817, 0.07075, 0.07323, 0.07563, 0.07796, 0.08021, 0.08242, 0.08455, 0.08664, 0.08869, 0.09069, 0.09262, 0.09455, 0.0964, 0.09825, 0.1001, 0.1018, 0.1036, 0.1053, 0.107, 0.1086, 0.1103, 0.1119;
0.02687, 0.0329, 0.03798, 0.04248, 0.04652, 0.05024, 0.05371, 0.05698, 0.06005, 0.06301, 0.0658, 0.06847, 0.07107, 0.07355, 0.07598, 0.07831, 0.08059, 0.08279, 0.08494, 0.08705, 0.08908, 0.09109, 0.09304, 0.09497, 0.09684, 0.09869, 0.1005, 0.1023, 0.104, 0.1058, 0.1074, 0.1091, 0.1108, 0.1124;
0.02699, 0.03304, 0.03816, 0.04268, 0.04675, 0.05047, 0.05398, 0.05723, 0.06033, 0.06328, 0.06608, 0.0688, 0.0714, 0.0739, 0.07633, 0.07866, 0.08096, 0.08316, 0.08533, 0.08743, 0.0895, 0.0915, 0.09349, 0.0954, 0.0973, 0.09915, 0.101, 0.1027, 0.1045, 0.1062, 0.1079, 0.1096, 0.1112, 0.1129;
0.02712, 0.03321, 0.03833, 0.04286, 0.04695, 0.05072, 0.05422, 0.0575, 0.06062, 0.06357, 0.0664, 0.06913, 0.07174, 0.07424, 0.07668, 0.07904, 0.08134, 0.08356, 0.08572, 0.08784, 0.08993, 0.09195, 0.09392, 0.09584, 0.09775, 0.09961, 0.1014, 0.1032, 0.105, 0.1067, 0.1084, 0.1101, 0.1118, 0.1134;
0.02726, 0.03338, 0.03854, 0.04307, 0.04719, 0.05096, 0.05447, 0.05779, 0.06092, 0.06389, 0.06673, 0.06945, 0.07208, 0.07461, 0.07706, 0.07942, 0.08172, 0.08396, 0.08615, 0.08828, 0.09036, 0.0924, 0.09438, 0.09632, 0.09823, 0.1001, 0.1019, 0.1037, 0.1055, 0.1072, 0.109, 0.1107, 0.1123, 0.114;
0.02739, 0.03353, 0.03871, 0.0433, 0.04743, 0.05123, 0.05476, 0.05808, 0.06121, 0.06421, 0.06707, 0.06981, 0.07245, 0.07499, 0.07744, 0.07983, 0.08213, 0.0844, 0.08658, 0.08871, 0.09081, 0.09284, 0.09483, 0.09681, 0.09871, 0.1006, 0.1024, 0.1043, 0.106, 0.1078, 0.1095, 0.1112, 0.1129, 0.1145;
0.02753, 0.03371, 0.03891, 0.04353, 0.04767, 0.05149, 0.05504, 0.05838, 0.06154, 0.06453, 0.06742, 0.07017, 0.07282, 0.07538, 0.07784, 0.08023, 0.08256, 0.08482, 0.08703, 0.08918, 0.09128, 0.09332, 0.09533, 0.09729, 0.09923, 0.1011, 0.103, 0.1048, 0.1066, 0.1084, 0.1101, 0.1118, 0.1135, 0.1151;
0.02767, 0.03388, 0.03914, 0.04375, 0.04794, 0.05176, 0.05533, 0.05871, 0.06187, 0.06489, 0.06777, 0.07055, 0.07321, 0.07578, 0.07827, 0.08067, 0.083, 0.0853, 0.0875, 0.08965, 0.09176, 0.09382, 0.09585, 0.09783, 0.09976, 0.1017, 0.1035, 0.1054, 0.1072, 0.1089, 0.1107, 0.1124, 0.1141, 0.1158;
0.02783, 0.03407, 0.03936, 0.04398, 0.04821, 0.05206, 0.05565, 0.05901, 0.06222, 0.06524, 0.06814, 0.07094, 0.07362, 0.0762, 0.0787, 0.08113, 0.08347, 0.08576, 0.088, 0.09017, 0.09228, 0.09436, 0.09638, 0.09837, 0.1003, 0.1022, 0.1041, 0.106, 0.1078, 0.1096, 0.1113, 0.113, 0.1147, 0.1164;
0.02798, 0.03427, 0.03959, 0.04424, 0.04846, 0.05235, 0.05596, 0.05937, 0.06258, 0.06563, 0.06856, 0.07135, 0.07405, 0.07664, 0.07915, 0.08159, 0.08396, 0.08626, 0.0885, 0.09069, 0.09283, 0.0949, 0.09694, 0.09896, 0.1009, 0.1028, 0.1047, 0.1066, 0.1084, 0.1102, 0.1119, 0.1137, 0.1154, 0.1171;
0.02816, 0.0345, 0.03983, 0.04452, 0.04876, 0.05269, 0.05632, 0.05975, 0.06297, 0.06602, 0.06898, 0.07179, 0.07451, 0.07711, 0.07964, 0.08209, 0.08447, 0.0868, 0.08904, 0.09123, 0.09339, 0.09549, 0.09756, 0.09956, 0.1015, 0.1035, 0.1053, 0.1072, 0.1091, 0.1108, 0.1126, 0.1144, 0.1161, 0.1178;
0.02835, 0.03471, 0.04008, 0.04482, 0.04908, 0.05301, 0.05668, 0.06013, 0.06335, 0.06648, 0.06941, 0.07224, 0.07498, 0.0776, 0.08014, 0.08264, 0.08502, 0.08736, 0.08963, 0.09183, 0.09399, 0.09611, 0.09817, 0.1002, 0.1022, 0.1041, 0.106, 0.1079, 0.1097, 0.1116, 0.1134, 0.1151, 0.1169, 0.1185;
0.02856, 0.03494, 0.04035, 0.04511, 0.04943, 0.05338, 0.05708, 0.06054, 0.06382, 0.06692, 0.06988, 0.07274, 0.07551, 0.07815, 0.08071, 0.08318, 0.08561, 0.08796, 0.09023, 0.09246, 0.09462, 0.09675, 0.09883, 0.1009, 0.1029, 0.1048, 0.1068, 0.1087, 0.1105, 0.1124, 0.1141, 0.1159, 0.1176, 0.1194;
0.02873, 0.03519, 0.04066, 0.04544, 0.04979, 0.05379, 0.05749, 0.06099, 0.06428, 0.06742, 0.07042, 0.07328, 0.07604, 0.07871, 0.08128, 0.08381, 0.08621, 0.08861, 0.09088, 0.09312, 0.09532, 0.09747, 0.09956, 0.1016, 0.1036, 0.1056, 0.1075, 0.1094, 0.1113, 0.1131, 0.115, 0.1168, 0.1185, 0.1202;
0.02898, 0.03549, 0.04098, 0.04578, 0.05018, 0.0542, 0.05794, 0.06147, 0.06478, 0.06794, 0.07094, 0.07384, 0.07663, 0.07933, 0.08193, 0.08447, 0.08689, 0.0893, 0.09159, 0.09387, 0.09607, 0.09823, 0.1004, 0.1024, 0.1044, 0.1064, 0.1084, 0.1103, 0.1122, 0.1141, 0.1159, 0.1177, 0.1194, 0.1212;
0.02924, 0.03581, 0.04134, 0.04621, 0.05061, 0.05466, 0.05841, 0.06198, 0.06532, 0.06853, 0.07155, 0.07449, 0.07728, 0.08001, 0.08264, 0.08517, 0.08765, 0.09004, 0.09238, 0.09467, 0.09688, 0.09909, 0.1012, 0.1033, 0.1053, 0.1073, 0.1093, 0.1112, 0.1132, 0.115, 0.1169, 0.1187, 0.1205, 0.1222;
0.02952, 0.03612, 0.0417, 0.04663, 0.05109, 0.05517, 0.05898, 0.06255, 0.06593, 0.06917, 0.07224, 0.0752, 0.07803, 0.08076, 0.08343, 0.08599, 0.08846, 0.09091, 0.09327, 0.09555, 0.09781, 0.09999, 0.1022, 0.1043, 0.1063, 0.1084, 0.1103, 0.1123, 0.1142, 0.1161, 0.118, 0.1198, 0.1216, 0.1234;
0.0298, 0.03652, 0.04217, 0.04711, 0.0516, 0.05573, 0.05963, 0.06321, 0.06663, 0.06991, 0.07301, 0.07599, 0.07884, 0.08162, 0.08429, 0.08689, 0.0894, 0.09184, 0.09423, 0.09657, 0.09882, 0.1011, 0.1032, 0.1054, 0.1074, 0.1095, 0.1115, 0.1135, 0.1154, 0.1173, 0.1192, 0.121, 0.1229, 0.1247;
0.03016, 0.03698, 0.04267, 0.0477, 0.05224, 0.05644, 0.06034, 0.064, 0.06744, 0.07072, 0.07387, 0.07692, 0.0798, 0.0826, 0.08534, 0.08796, 0.09051, 0.09296, 0.09539, 0.09773, 0.1001, 0.1023, 0.1045, 0.1067, 0.1087, 0.1108, 0.1129, 0.1148, 0.1168, 0.1187, 0.1207, 0.1225, 0.1244, 0.1262;
0.03062, 0.03747, 0.04325, 0.04842, 0.05298, 0.05724, 0.06121, 0.06493, 0.06841, 0.07178, 0.07494, 0.07801, 0.08099, 0.08379, 0.08656, 0.08921, 0.09179, 0.09431, 0.09676, 0.09916, 0.1015, 0.1038, 0.106, 0.1082, 0.1103, 0.1125, 0.1145, 0.1165, 0.1185, 0.1205, 0.1224, 0.1243, 0.1262, 0.128;
0.03117, 0.03821, 0.04409, 0.04927, 0.05398, 0.05827, 0.06232, 0.06609, 0.06966, 0.07311, 0.07633, 0.07945, 0.08247, 0.08535, 0.08814, 0.09086, 0.0935, 0.09602, 0.09853, 0.101, 0.1034, 0.1057, 0.1079, 0.1102, 0.1124, 0.1145, 0.1166, 0.1187, 0.1207, 0.1227, 0.1247, 0.1266, 0.1285, 0.1303;
];
% Flatten the data for fitting
[X, Y] = meshgrid(PressureInlet, dP);
Z = values;
% Fit a 2D polynomial surface of degree 3 (example)
ft = fittype('poly33'); % poly33 degree of the for the x terms and degree of three for the y terms
f = fit([X(:), Y(:)], Z(:), ft);
% Display the fitted model
disp(f);
Linear model Poly33: f(x,y) = p00 + p10*x + p01*y + p20*x^2 + p11*x*y + p02*y^2 + p30*x^3 + p21*x^2*y + p12*x*y^2 + p03*y^3 Coefficients (with 95% confidence bounds): p00 = -0.6591 (-0.7375, -0.5808) p10 = 0.03077 (0.02663, 0.03491) p01 = 0.002186 (0.0008929, 0.00348) p20 = -0.0004397 (-0.0005123, -0.000367) p11 = -5.06e-05 (-9.079e-05, -1.04e-05) p02 = -3.561e-05 (-6.072e-05, -1.049e-05) p30 = 2.255e-06 (1.832e-06, 2.678e-06) p21 = 2.155e-07 (-1.218e-07, 5.529e-07) p12 = 6.127e-07 (3.052e-07, 9.202e-07) p03 = 7.151e-08 (-2.488e-07, 3.918e-07)
coeffvalues(f)
ans = 1×10
-0.6591 0.0308 0.0022 -0.0004 -0.0001 -0.0000 0.0000 0.0000 0.0000 0.0000
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
newdP = 6;
newHPressureInlet = 55;
value = feval(f, newHPressureInlet, newdP)
value = 0.0787

3 件のコメント

Andrei
Andrei 2025 年 4 月 11 日
移動済み: John D'Errico 2025 年 4 月 11 日
Hi, thank you all for the support. I have faced another challange now, when data is abit more complex.
Pressue varies from 8 to 70
Temperature varies from -46 to 30
example: Fixed Pressure 10 Bar; Temperature (-46...+30 with a step of 0.1) is:
[ 1140.08, 1139.7, 1139.31, 1138.92, 1138.54, 1138.15, 1137.76, 1137.37, 1136.99, 1136.6, 1136.21, 1135.82, 1135.43, 1135.04, 1134.65, 1134.26, 1133.87, 1133.48, 1133.09, 1132.7, 1132.31, 1131.92, 1131.53, 1131.13, 1130.74, 1130.35, 1129.96, 1129.56, 1129.17, 1128.78, 1128.38, 1127.99, 1127.59, 1127.2, 1126.8, 1126.41, 1126.01, 1125.61, 1125.22, 1124.82, 1124.42, 1124.02, 1123.63, 1123.23, 1122.83, 1122.43, 1122.03, 1121.63, 1121.23, 1120.83, 1120.43, 1120.03, 1119.63, 1119.23, 1118.83, 1118.43, 1118.02, 1117.62, 1117.22, 26, 25.98, 25.97, 25.95, 25.93, 25.91, 25.9, 25.88, 25.86, 25.84, 25.83, 25.81, 25.79, 25.78, 25.76, 25.74, 25.72, 25.71, 25.69, 25.67, 25.66, 25.64, 25.62, 25.61, 25.59, 25.57, 25.56, 25.54, 25.52, 25.51, 25.49, 25.47, 25.46, 25.44, 25.42, 25.41, 25.39, 25.37, 25.36, 25.34, 25.32, 25.31, 25.29, 25.28, 25.26, 25.24, 25.23, 25.21, 25.2, 25.18, 25.16, 25.15, 25.13, 25.12, 25.1, 25.08, 25.07, 25.05, 25.04, 25.02, 25, 24.99, 24.97, 24.96, 24.94, 24.93, 24.91, 24.9, 24.88, 24.86, 24.85, 24.83, 24.82, 24.8, 24.79, 24.77, 24.76, 24.74, 24.73, 24.71, 24.7, 24.68, 24.67, 24.65, 24.64, 24.62, 24.61, 24.59, 24.58, 24.56, 24.55, 24.53, 24.52, 24.5, 24.49, 24.47, 24.46, 24.44, 24.43, 24.41, 24.4, 24.38, 24.37, 24.35, 24.34, 24.32, 24.31, 24.3, 24.28, 24.27, 24.25, 24.24, 24.22, 24.21, 24.2, 24.18, 24.17, 24.15, 24.14, 24.12, 24.11, 24.1, 24.08, 24.07, 24.05, 24.04, 24.03, 24.01, 24, 23.98, 23.97, 23.96, 23.94, 23.93, 23.91, 23.9, 23.89, 23.87, 23.86, 23.84, 23.83, 23.82, 23.8, 23.79, 23.78, 23.76, 23.75, 23.74, 23.72, 23.71, 23.69, 23.68, 23.67, 23.65, 23.64, 23.63, 23.61, 23.6, 23.59, 23.57, 23.56, 23.55, 23.53, 23.52, 23.51, 23.49, 23.48, 23.47, 23.45, 23.44, 23.43, 23.42, 23.4, 23.39, 23.38, 23.36, 23.35, 23.34, 23.32, 23.31, 23.3, 23.29, 23.27, 23.26, 23.25, 23.23, 23.22, 23.21, 23.2, 23.18, 23.17, 23.16, 23.15, 23.13, 23.12, 23.11, 23.09, 23.08, 23.07, 23.06, 23.04, 23.03, 23.02, 23.01, 22.99, 22.98, 22.97, 22.96, 22.94, 22.93, 22.92, 22.91, 22.9, 22.88, 22.87, 22.86, 22.85, 22.83, 22.82, 22.81, 22.8, 22.79, 22.77, 22.76, 22.75, 22.74, 22.72, 22.71, 22.7, 22.69, 22.68, 22.66, 22.65, 22.64, 22.63, 22.62, 22.6, 22.59, 22.58, 22.57, 22.56, 22.55, 22.53, 22.52, 22.51, 22.5, 22.49, 22.47, 22.46, 22.45, 22.44, 22.43, 22.42, 22.4, 22.39, 22.38, 22.37, 22.36, 22.35, 22.34, 22.32, 22.31, 22.3, 22.29, 22.28, 22.27, 22.25, 22.24, 22.23, 22.22, 22.21, 22.2, 22.19, 22.18, 22.16, 22.15, 22.14, 22.13, 22.12, 22.11, 22.1, 22.09, 22.07, 22.06, 22.05, 22.04, 22.03, 22.02, 22.01, 22, 21.98, 21.97, 21.96, 21.95, 21.94, 21.93, 21.92, 21.91, 21.9, 21.89, 21.87, 21.86, 21.85, 21.84, 21.83, 21.82, 21.81, 21.8, 21.79, 21.78, 21.77, 21.76, 21.74, 21.73, 21.72, 21.71, 21.7, 21.69, 21.68, 21.67, 21.66, 21.65, 21.64, 21.63, 21.62, 21.61, 21.6, 21.58, 21.57, 21.56, 21.55, 21.54, 21.53, 21.52, 21.51, 21.5, 21.49, 21.48, 21.47, 21.46, 21.45, 21.44, 21.43, 21.42, 21.41, 21.4, 21.39, 21.38, 21.37, 21.36, 21.34, 21.33, 21.32, 21.31, 21.3, 21.29, 21.28, 21.27, 21.26, 21.25, 21.24, 21.23, 21.22, 21.21, 21.2, 21.19, 21.18, 21.17, 21.16, 21.15, 21.14, 21.13, 21.12, 21.11, 21.1, 21.09, 21.08, 21.07, 21.06, 21.05, 21.04, 21.03, 21.02, 21.01, 21, 20.99, 20.98, 20.97, 20.96, 20.95, 20.94, 20.93, 20.92, 20.91, 20.9, 20.89, 20.89, 20.88, 20.87, 20.86, 20.85, 20.84, 20.83, 20.82, 20.81, 20.8, 20.79, 20.78, 20.77, 20.76, 20.75, 20.74, 20.73, 20.72, 20.71, 20.7, 20.69, 20.68, 20.67, 20.66, 20.66, 20.65, 20.64, 20.63, 20.62, 20.61, 20.6, 20.59, 20.58, 20.57, 20.56, 20.55, 20.54, 20.53, 20.52, 20.51, 20.5, 20.5, 20.49, 20.48, 20.47, 20.46, 20.45, 20.44, 20.43, 20.42, 20.41, 20.4, 20.39, 20.39, 20.38, 20.37, 20.36, 20.35, 20.34, 20.33, 20.32, 20.31, 20.3, 20.29, 20.28, 20.28, 20.27, 20.26, 20.25, 20.24, 20.23, 20.22, 20.21, 20.2, 20.19, 20.19, 20.18, 20.17, 20.16, 20.15, 20.14, 20.13, 20.12, 20.11, 20.11, 20.1, 20.09, 20.08, 20.07, 20.06, 20.05, 20.04, 20.04, 20.03, 20.02, 20.01, 20, 19.99, 19.98, 19.97, 19.97, 19.96, 19.95, 19.94, 19.93, 19.92, 19.91, 19.9, 19.9, 19.89, 19.88, 19.87, 19.86, 19.85, 19.84, 19.84, 19.83, 19.82, 19.81, 19.8, 19.79, 19.78, 19.78, 19.77, 19.76, 19.75, 19.74, 19.73, 19.72, 19.72, 19.71, 19.7, 19.69, 19.68, 19.67, 19.67, 19.66, 19.65, 19.64, 19.63, 19.62, 19.62, 19.61, 19.6, 19.59, 19.58, 19.57, 19.57, 19.56, 19.55, 19.54, 19.53, 19.52, 19.52, 19.51, 19.5, 19.49, 19.48, 19.48, 19.47, 19.46, 19.45, 19.44, 19.43, 19.43, 19.42, 19.41, 19.4, 19.39, 19.39, 19.38, 19.37, 19.36, 19.35, 19.34, 19.34, 19.33, 19.32, 19.31, 19.3, 19.3, 19.29, 19.28, 19.27, 19.26, 19.26, 19.25, 19.24, 19.23, 19.22, 19.22, 19.21, 19.2, 19.19, 19.19, 19.18, 19.17, 19.16, 19.15, 19.15, 19.14, 19.13, 19.12, 19.11, 19.11, 19.1, 19.09, 19.08, 19.08, 19.07, 19.06, 19.05, 19.04, 19.04, 19.03, 19.02, 19.01, 19.01, 19, 18.99, 18.98, 18.97, 18.97, 18.96, 18.95, 18.94, 18.94, 18.93, 18.92, 18.91, 18.91, 18.9, 18.89, 18.88, 18.87, 18.87, 18.86, 18.85, 18.84, 18.84, 18.83, 18.82, 18.81, 18.81, 18.8, 18.79, 18.78, 18.78, 18.77, 18.76, 18.75, 18.75, 18.74, 18.73, 18.72, 18.72, 18.71, 18.7, 18.69, 18.69, 18.68, 18.67, 18.66, 18.66, 18.65, 18.64, 18.63, 18.63, 18.62, 18.61, 18.61, 18.6, 18.59, 18.58, 18.58, 18.57, 18.56, 18.55, 18.55, 18.54, 18.53, 18.52, 18.52, 18.51, 18.5, 18.5, 18.49, 18.48, 18.47, 18.47, 18.46, 18.45, 18.44, 18.44, 18.43, 18.42, 18.42, 18.41, 18.4, 18.39, 18.39, 18.38, 18.37, 18.37, 18.36, 18.35; ]
Polynomial isn't getting even near to the values i need. Thank you
Torsten
Torsten 2025 年 4 月 11 日
移動済み: John D'Errico 2025 年 4 月 11 日
Polynomial approximation is not suited for discontinuous functions. Try "interp2" instead - a local interpolation method instead of a global one with polynomials.
John D'Errico
John D'Errico 2025 年 4 月 11 日
編集済み: John D'Errico 2025 年 4 月 11 日
@Andrei Please do not add an answer just to sk a second question. I moved your "answer" that was not an answer, to a comment on your own question.
Next, the data you show is NOT a single valued function! At any point in the temperature/pressure plane, your picture shows TWO possible values, one down near zero, the other near 1000. You cannot fit a polynomial or any single valued relationship to that result. If you try to do so, you will get garbage, much as you found.

サインインしてコメントする。

回答 (2 件)

Torsten
Torsten 2024 年 10 月 14 日
編集済み: Torsten 2024 年 10 月 14 日

0 投票

You can't expect exact agreement, but the approximation is not that bad (at least for the point chosen):
% Data preparation
dP = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35];
PressureInlet = [42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72];
values = [
0.02568, 0.03147, 0.03633, 0.04062, 0.0445, 0.04807, 0.05138, 0.05451, 0.05745, 0.06026, 0.06292, 0.06549, 0.06797, 0.07036, 0.07267, 0.0749, 0.07708, 0.07918, 0.08124, 0.08325, 0.08521, 0.08713, 0.08899, 0.09083, 0.09264, 0.09439, 0.09613, 0.09782, 0.0995, 0.1012, 0.1028, 0.1044, 0.1059, 0.1075;
0.02579, 0.03159, 0.03647, 0.04078, 0.04466, 0.04825, 0.05157, 0.0547, 0.05766, 0.06048, 0.06316, 0.06574, 0.06823, 0.07062, 0.07294, 0.07519, 0.07737, 0.07949, 0.08155, 0.08355, 0.08553, 0.08745, 0.08933, 0.09116, 0.09298, 0.09475, 0.09648, 0.09819, 0.09986, 0.1015, 0.1031, 0.1048, 0.1063, 0.1079;
0.02588, 0.03171, 0.0366, 0.04092, 0.04483, 0.04843, 0.05178, 0.05491, 0.05788, 0.06071, 0.0634, 0.06599, 0.06849, 0.07089, 0.07322, 0.07546, 0.07766, 0.07977, 0.08186, 0.08387, 0.08584, 0.08778, 0.08968, 0.09151, 0.09332, 0.0951, 0.09686, 0.09857, 0.1003, 0.1019, 0.1035, 0.1052, 0.1067, 0.1083;
0.02598, 0.03183, 0.03675, 0.04108, 0.045, 0.04862, 0.05198, 0.05511, 0.0581, 0.06095, 0.06365, 0.06624, 0.06875, 0.07116, 0.0735, 0.07575, 0.07796, 0.08009, 0.08216, 0.08421, 0.08618, 0.08812, 0.09002, 0.09187, 0.09368, 0.09547, 0.09722, 0.09894, 0.1006, 0.1023, 0.1039, 0.1055, 0.1071, 0.1087;
0.02608, 0.03195, 0.03689, 0.04125, 0.04519, 0.04881, 0.05218, 0.05534, 0.05832, 0.06117, 0.0639, 0.0665, 0.06902, 0.07143, 0.07377, 0.07606, 0.07826, 0.08041, 0.0825, 0.08453, 0.08651, 0.08846, 0.09036, 0.09223, 0.09406, 0.09584, 0.0976, 0.09933, 0.101, 0.1027, 0.1043, 0.106, 0.1076, 0.1091;
0.02619, 0.03208, 0.03703, 0.04141, 0.04535, 0.04898, 0.05238, 0.05555, 0.05855, 0.06141, 0.06414, 0.06677, 0.0693, 0.07173, 0.07408, 0.07636, 0.07856, 0.08072, 0.08282, 0.08487, 0.08686, 0.08881, 0.09071, 0.09259, 0.09443, 0.09623, 0.09799, 0.09972, 0.1014, 0.1031, 0.1048, 0.1064, 0.108, 0.1096;
0.02629, 0.03219, 0.03719, 0.04157, 0.04554, 0.04919, 0.0526, 0.05577, 0.05879, 0.06167, 0.06441, 0.06703, 0.06956, 0.072, 0.07437, 0.07665, 0.07887, 0.08105, 0.08314, 0.0852, 0.08722, 0.08916, 0.09109, 0.09296, 0.09481, 0.0966, 0.09837, 0.1001, 0.1018, 0.1035, 0.1052, 0.1068, 0.1084, 0.11;
0.02639, 0.03233, 0.03734, 0.04174, 0.04573, 0.0494, 0.0528, 0.056, 0.05904, 0.06192, 0.06467, 0.0673, 0.06986, 0.0723, 0.07467, 0.07698, 0.07922, 0.08137, 0.0835, 0.08554, 0.08757, 0.08954, 0.09145, 0.09333, 0.09518, 0.097, 0.09879, 0.1005, 0.1022, 0.1039, 0.1056, 0.1073, 0.1089, 0.1105;
0.0265, 0.03248, 0.0375, 0.04191, 0.04591, 0.0496, 0.05303, 0.05623, 0.05928, 0.06217, 0.06494, 0.06758, 0.07015, 0.0726, 0.07499, 0.0773, 0.07953, 0.08172, 0.08384, 0.0859, 0.08792, 0.0899, 0.09184, 0.09373, 0.09558, 0.09742, 0.09921, 0.1009, 0.1027, 0.1044, 0.1061, 0.1077, 0.1093, 0.1109;
0.02662, 0.03261, 0.03764, 0.0421, 0.04612, 0.04981, 0.05325, 0.05648, 0.05953, 0.06244, 0.06523, 0.06788, 0.07045, 0.0729, 0.0753, 0.07763, 0.07989, 0.08207, 0.08419, 0.08628, 0.08829, 0.09028, 0.09223, 0.09412, 0.096, 0.09782, 0.09963, 0.1014, 0.1031, 0.1048, 0.1065, 0.1082, 0.1098, 0.1114;
0.02674, 0.03275, 0.03782, 0.04229, 0.04633, 0.05003, 0.05349, 0.05672, 0.0598, 0.0627, 0.0655, 0.06817, 0.07075, 0.07323, 0.07563, 0.07796, 0.08021, 0.08242, 0.08455, 0.08664, 0.08869, 0.09069, 0.09262, 0.09455, 0.0964, 0.09825, 0.1001, 0.1018, 0.1036, 0.1053, 0.107, 0.1086, 0.1103, 0.1119;
0.02687, 0.0329, 0.03798, 0.04248, 0.04652, 0.05024, 0.05371, 0.05698, 0.06005, 0.06301, 0.0658, 0.06847, 0.07107, 0.07355, 0.07598, 0.07831, 0.08059, 0.08279, 0.08494, 0.08705, 0.08908, 0.09109, 0.09304, 0.09497, 0.09684, 0.09869, 0.1005, 0.1023, 0.104, 0.1058, 0.1074, 0.1091, 0.1108, 0.1124;
0.02699, 0.03304, 0.03816, 0.04268, 0.04675, 0.05047, 0.05398, 0.05723, 0.06033, 0.06328, 0.06608, 0.0688, 0.0714, 0.0739, 0.07633, 0.07866, 0.08096, 0.08316, 0.08533, 0.08743, 0.0895, 0.0915, 0.09349, 0.0954, 0.0973, 0.09915, 0.101, 0.1027, 0.1045, 0.1062, 0.1079, 0.1096, 0.1112, 0.1129;
0.02712, 0.03321, 0.03833, 0.04286, 0.04695, 0.05072, 0.05422, 0.0575, 0.06062, 0.06357, 0.0664, 0.06913, 0.07174, 0.07424, 0.07668, 0.07904, 0.08134, 0.08356, 0.08572, 0.08784, 0.08993, 0.09195, 0.09392, 0.09584, 0.09775, 0.09961, 0.1014, 0.1032, 0.105, 0.1067, 0.1084, 0.1101, 0.1118, 0.1134;
0.02726, 0.03338, 0.03854, 0.04307, 0.04719, 0.05096, 0.05447, 0.05779, 0.06092, 0.06389, 0.06673, 0.06945, 0.07208, 0.07461, 0.07706, 0.07942, 0.08172, 0.08396, 0.08615, 0.08828, 0.09036, 0.0924, 0.09438, 0.09632, 0.09823, 0.1001, 0.1019, 0.1037, 0.1055, 0.1072, 0.109, 0.1107, 0.1123, 0.114;
0.02739, 0.03353, 0.03871, 0.0433, 0.04743, 0.05123, 0.05476, 0.05808, 0.06121, 0.06421, 0.06707, 0.06981, 0.07245, 0.07499, 0.07744, 0.07983, 0.08213, 0.0844, 0.08658, 0.08871, 0.09081, 0.09284, 0.09483, 0.09681, 0.09871, 0.1006, 0.1024, 0.1043, 0.106, 0.1078, 0.1095, 0.1112, 0.1129, 0.1145;
0.02753, 0.03371, 0.03891, 0.04353, 0.04767, 0.05149, 0.05504, 0.05838, 0.06154, 0.06453, 0.06742, 0.07017, 0.07282, 0.07538, 0.07784, 0.08023, 0.08256, 0.08482, 0.08703, 0.08918, 0.09128, 0.09332, 0.09533, 0.09729, 0.09923, 0.1011, 0.103, 0.1048, 0.1066, 0.1084, 0.1101, 0.1118, 0.1135, 0.1151;
0.02767, 0.03388, 0.03914, 0.04375, 0.04794, 0.05176, 0.05533, 0.05871, 0.06187, 0.06489, 0.06777, 0.07055, 0.07321, 0.07578, 0.07827, 0.08067, 0.083, 0.0853, 0.0875, 0.08965, 0.09176, 0.09382, 0.09585, 0.09783, 0.09976, 0.1017, 0.1035, 0.1054, 0.1072, 0.1089, 0.1107, 0.1124, 0.1141, 0.1158;
0.02783, 0.03407, 0.03936, 0.04398, 0.04821, 0.05206, 0.05565, 0.05901, 0.06222, 0.06524, 0.06814, 0.07094, 0.07362, 0.0762, 0.0787, 0.08113, 0.08347, 0.08576, 0.088, 0.09017, 0.09228, 0.09436, 0.09638, 0.09837, 0.1003, 0.1022, 0.1041, 0.106, 0.1078, 0.1096, 0.1113, 0.113, 0.1147, 0.1164;
0.02798, 0.03427, 0.03959, 0.04424, 0.04846, 0.05235, 0.05596, 0.05937, 0.06258, 0.06563, 0.06856, 0.07135, 0.07405, 0.07664, 0.07915, 0.08159, 0.08396, 0.08626, 0.0885, 0.09069, 0.09283, 0.0949, 0.09694, 0.09896, 0.1009, 0.1028, 0.1047, 0.1066, 0.1084, 0.1102, 0.1119, 0.1137, 0.1154, 0.1171;
0.02816, 0.0345, 0.03983, 0.04452, 0.04876, 0.05269, 0.05632, 0.05975, 0.06297, 0.06602, 0.06898, 0.07179, 0.07451, 0.07711, 0.07964, 0.08209, 0.08447, 0.0868, 0.08904, 0.09123, 0.09339, 0.09549, 0.09756, 0.09956, 0.1015, 0.1035, 0.1053, 0.1072, 0.1091, 0.1108, 0.1126, 0.1144, 0.1161, 0.1178;
0.02835, 0.03471, 0.04008, 0.04482, 0.04908, 0.05301, 0.05668, 0.06013, 0.06335, 0.06648, 0.06941, 0.07224, 0.07498, 0.0776, 0.08014, 0.08264, 0.08502, 0.08736, 0.08963, 0.09183, 0.09399, 0.09611, 0.09817, 0.1002, 0.1022, 0.1041, 0.106, 0.1079, 0.1097, 0.1116, 0.1134, 0.1151, 0.1169, 0.1185;
0.02856, 0.03494, 0.04035, 0.04511, 0.04943, 0.05338, 0.05708, 0.06054, 0.06382, 0.06692, 0.06988, 0.07274, 0.07551, 0.07815, 0.08071, 0.08318, 0.08561, 0.08796, 0.09023, 0.09246, 0.09462, 0.09675, 0.09883, 0.1009, 0.1029, 0.1048, 0.1068, 0.1087, 0.1105, 0.1124, 0.1141, 0.1159, 0.1176, 0.1194;
0.02873, 0.03519, 0.04066, 0.04544, 0.04979, 0.05379, 0.05749, 0.06099, 0.06428, 0.06742, 0.07042, 0.07328, 0.07604, 0.07871, 0.08128, 0.08381, 0.08621, 0.08861, 0.09088, 0.09312, 0.09532, 0.09747, 0.09956, 0.1016, 0.1036, 0.1056, 0.1075, 0.1094, 0.1113, 0.1131, 0.115, 0.1168, 0.1185, 0.1202;
0.02898, 0.03549, 0.04098, 0.04578, 0.05018, 0.0542, 0.05794, 0.06147, 0.06478, 0.06794, 0.07094, 0.07384, 0.07663, 0.07933, 0.08193, 0.08447, 0.08689, 0.0893, 0.09159, 0.09387, 0.09607, 0.09823, 0.1004, 0.1024, 0.1044, 0.1064, 0.1084, 0.1103, 0.1122, 0.1141, 0.1159, 0.1177, 0.1194, 0.1212;
0.02924, 0.03581, 0.04134, 0.04621, 0.05061, 0.05466, 0.05841, 0.06198, 0.06532, 0.06853, 0.07155, 0.07449, 0.07728, 0.08001, 0.08264, 0.08517, 0.08765, 0.09004, 0.09238, 0.09467, 0.09688, 0.09909, 0.1012, 0.1033, 0.1053, 0.1073, 0.1093, 0.1112, 0.1132, 0.115, 0.1169, 0.1187, 0.1205, 0.1222;
0.02952, 0.03612, 0.0417, 0.04663, 0.05109, 0.05517, 0.05898, 0.06255, 0.06593, 0.06917, 0.07224, 0.0752, 0.07803, 0.08076, 0.08343, 0.08599, 0.08846, 0.09091, 0.09327, 0.09555, 0.09781, 0.09999, 0.1022, 0.1043, 0.1063, 0.1084, 0.1103, 0.1123, 0.1142, 0.1161, 0.118, 0.1198, 0.1216, 0.1234;
0.0298, 0.03652, 0.04217, 0.04711, 0.0516, 0.05573, 0.05963, 0.06321, 0.06663, 0.06991, 0.07301, 0.07599, 0.07884, 0.08162, 0.08429, 0.08689, 0.0894, 0.09184, 0.09423, 0.09657, 0.09882, 0.1011, 0.1032, 0.1054, 0.1074, 0.1095, 0.1115, 0.1135, 0.1154, 0.1173, 0.1192, 0.121, 0.1229, 0.1247;
0.03016, 0.03698, 0.04267, 0.0477, 0.05224, 0.05644, 0.06034, 0.064, 0.06744, 0.07072, 0.07387, 0.07692, 0.0798, 0.0826, 0.08534, 0.08796, 0.09051, 0.09296, 0.09539, 0.09773, 0.1001, 0.1023, 0.1045, 0.1067, 0.1087, 0.1108, 0.1129, 0.1148, 0.1168, 0.1187, 0.1207, 0.1225, 0.1244, 0.1262;
0.03062, 0.03747, 0.04325, 0.04842, 0.05298, 0.05724, 0.06121, 0.06493, 0.06841, 0.07178, 0.07494, 0.07801, 0.08099, 0.08379, 0.08656, 0.08921, 0.09179, 0.09431, 0.09676, 0.09916, 0.1015, 0.1038, 0.106, 0.1082, 0.1103, 0.1125, 0.1145, 0.1165, 0.1185, 0.1205, 0.1224, 0.1243, 0.1262, 0.128;
0.03117, 0.03821, 0.04409, 0.04927, 0.05398, 0.05827, 0.06232, 0.06609, 0.06966, 0.07311, 0.07633, 0.07945, 0.08247, 0.08535, 0.08814, 0.09086, 0.0935, 0.09602, 0.09853, 0.101, 0.1034, 0.1057, 0.1079, 0.1102, 0.1124, 0.1145, 0.1166, 0.1187, 0.1207, 0.1227, 0.1247, 0.1266, 0.1285, 0.1303;
];
for i = 1:31
for j = 1:34
X((i-1)*34+j) = PressureInlet(i);
Y((i-1)*34+j) = dP(j);
Z((i-1)*34+j) = values(i,j);
end
end
% Fit a 2D polynomial surface of degree 3 (example)
ft = fittype('poly33'); % poly33 degree of the for the x terms and degree of three for the y terms
f = fit([X(:), Y(:)], Z(:), ft);
% Display the fitted model
disp(f);
Linear model Poly33: f(x,y) = p00 + p10*x + p01*y + p20*x^2 + p11*x*y + p02*y^2 + p30*x^3 + p21*x^2*y + p12*x*y^2 + p03*y^3 Coefficients (with 95% confidence bounds): p00 = -0.07849 (-0.08929, -0.06769) p10 = 0.005311 (0.00474, 0.005882) p01 = 0.005251 (0.005072, 0.005429) p20 = -9.757e-05 (-0.0001076, -8.755e-05) p11 = -2.008e-05 (-2.562e-05, -1.453e-05) p02 = -0.0001141 (-0.0001176, -0.0001106) p30 = 6.018e-07 (5.435e-07, 6.601e-07) p21 = 3.848e-07 (3.383e-07, 4.313e-07) p12 = -2.503e-07 (-2.926e-07, -2.079e-07) p03 = 1.541e-06 (1.497e-06, 1.585e-06)
coeffvalues(f)
ans = 1×10
-0.0785 0.0053 0.0053 -0.0001 -0.0000 -0.0001 0.0000 0.0000 -0.0000 0.0000
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
newdP = 6;
newHPressureInlet = 55;
value = feval(f, newHPressureInlet, newdP)
value = 0.0462
values(14,5)
ans = 0.0469

8 件のコメント

Andrei
Andrei 2024 年 10 月 15 日
Thank you for your support. What actually you are trying to do in here? create an array? if yes, what is the reason of multiplying to 34?
for i = 1:31
for j = 1:34
X((i-1)*34+j) = PressureInlet(i);
Y((i-1)*34+j) = dP(j);
Z((i-1)*34+j) = values(i,j);
end
end
Sam Chak
Sam Chak 2024 年 10 月 15 日
The nonlinear surface generated from the given data looks very smooth. Thus, in theory, performing Bilinear interpolation using four nearest adjacent points should give you relatively accurate predictions.
% Data preparation
dP = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35];
PressureInlet = [42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72];
values = [
0.02568, 0.03147, 0.03633, 0.04062, 0.0445, 0.04807, 0.05138, 0.05451, 0.05745, 0.06026, 0.06292, 0.06549, 0.06797, 0.07036, 0.07267, 0.0749, 0.07708, 0.07918, 0.08124, 0.08325, 0.08521, 0.08713, 0.08899, 0.09083, 0.09264, 0.09439, 0.09613, 0.09782, 0.0995, 0.1012, 0.1028, 0.1044, 0.1059, 0.1075;
0.02579, 0.03159, 0.03647, 0.04078, 0.04466, 0.04825, 0.05157, 0.0547, 0.05766, 0.06048, 0.06316, 0.06574, 0.06823, 0.07062, 0.07294, 0.07519, 0.07737, 0.07949, 0.08155, 0.08355, 0.08553, 0.08745, 0.08933, 0.09116, 0.09298, 0.09475, 0.09648, 0.09819, 0.09986, 0.1015, 0.1031, 0.1048, 0.1063, 0.1079;
0.02588, 0.03171, 0.0366, 0.04092, 0.04483, 0.04843, 0.05178, 0.05491, 0.05788, 0.06071, 0.0634, 0.06599, 0.06849, 0.07089, 0.07322, 0.07546, 0.07766, 0.07977, 0.08186, 0.08387, 0.08584, 0.08778, 0.08968, 0.09151, 0.09332, 0.0951, 0.09686, 0.09857, 0.1003, 0.1019, 0.1035, 0.1052, 0.1067, 0.1083;
0.02598, 0.03183, 0.03675, 0.04108, 0.045, 0.04862, 0.05198, 0.05511, 0.0581, 0.06095, 0.06365, 0.06624, 0.06875, 0.07116, 0.0735, 0.07575, 0.07796, 0.08009, 0.08216, 0.08421, 0.08618, 0.08812, 0.09002, 0.09187, 0.09368, 0.09547, 0.09722, 0.09894, 0.1006, 0.1023, 0.1039, 0.1055, 0.1071, 0.1087;
0.02608, 0.03195, 0.03689, 0.04125, 0.04519, 0.04881, 0.05218, 0.05534, 0.05832, 0.06117, 0.0639, 0.0665, 0.06902, 0.07143, 0.07377, 0.07606, 0.07826, 0.08041, 0.0825, 0.08453, 0.08651, 0.08846, 0.09036, 0.09223, 0.09406, 0.09584, 0.0976, 0.09933, 0.101, 0.1027, 0.1043, 0.106, 0.1076, 0.1091;
0.02619, 0.03208, 0.03703, 0.04141, 0.04535, 0.04898, 0.05238, 0.05555, 0.05855, 0.06141, 0.06414, 0.06677, 0.0693, 0.07173, 0.07408, 0.07636, 0.07856, 0.08072, 0.08282, 0.08487, 0.08686, 0.08881, 0.09071, 0.09259, 0.09443, 0.09623, 0.09799, 0.09972, 0.1014, 0.1031, 0.1048, 0.1064, 0.108, 0.1096;
0.02629, 0.03219, 0.03719, 0.04157, 0.04554, 0.04919, 0.0526, 0.05577, 0.05879, 0.06167, 0.06441, 0.06703, 0.06956, 0.072, 0.07437, 0.07665, 0.07887, 0.08105, 0.08314, 0.0852, 0.08722, 0.08916, 0.09109, 0.09296, 0.09481, 0.0966, 0.09837, 0.1001, 0.1018, 0.1035, 0.1052, 0.1068, 0.1084, 0.11;
0.02639, 0.03233, 0.03734, 0.04174, 0.04573, 0.0494, 0.0528, 0.056, 0.05904, 0.06192, 0.06467, 0.0673, 0.06986, 0.0723, 0.07467, 0.07698, 0.07922, 0.08137, 0.0835, 0.08554, 0.08757, 0.08954, 0.09145, 0.09333, 0.09518, 0.097, 0.09879, 0.1005, 0.1022, 0.1039, 0.1056, 0.1073, 0.1089, 0.1105;
0.0265, 0.03248, 0.0375, 0.04191, 0.04591, 0.0496, 0.05303, 0.05623, 0.05928, 0.06217, 0.06494, 0.06758, 0.07015, 0.0726, 0.07499, 0.0773, 0.07953, 0.08172, 0.08384, 0.0859, 0.08792, 0.0899, 0.09184, 0.09373, 0.09558, 0.09742, 0.09921, 0.1009, 0.1027, 0.1044, 0.1061, 0.1077, 0.1093, 0.1109;
0.02662, 0.03261, 0.03764, 0.0421, 0.04612, 0.04981, 0.05325, 0.05648, 0.05953, 0.06244, 0.06523, 0.06788, 0.07045, 0.0729, 0.0753, 0.07763, 0.07989, 0.08207, 0.08419, 0.08628, 0.08829, 0.09028, 0.09223, 0.09412, 0.096, 0.09782, 0.09963, 0.1014, 0.1031, 0.1048, 0.1065, 0.1082, 0.1098, 0.1114;
0.02674, 0.03275, 0.03782, 0.04229, 0.04633, 0.05003, 0.05349, 0.05672, 0.0598, 0.0627, 0.0655, 0.06817, 0.07075, 0.07323, 0.07563, 0.07796, 0.08021, 0.08242, 0.08455, 0.08664, 0.08869, 0.09069, 0.09262, 0.09455, 0.0964, 0.09825, 0.1001, 0.1018, 0.1036, 0.1053, 0.107, 0.1086, 0.1103, 0.1119;
0.02687, 0.0329, 0.03798, 0.04248, 0.04652, 0.05024, 0.05371, 0.05698, 0.06005, 0.06301, 0.0658, 0.06847, 0.07107, 0.07355, 0.07598, 0.07831, 0.08059, 0.08279, 0.08494, 0.08705, 0.08908, 0.09109, 0.09304, 0.09497, 0.09684, 0.09869, 0.1005, 0.1023, 0.104, 0.1058, 0.1074, 0.1091, 0.1108, 0.1124;
0.02699, 0.03304, 0.03816, 0.04268, 0.04675, 0.05047, 0.05398, 0.05723, 0.06033, 0.06328, 0.06608, 0.0688, 0.0714, 0.0739, 0.07633, 0.07866, 0.08096, 0.08316, 0.08533, 0.08743, 0.0895, 0.0915, 0.09349, 0.0954, 0.0973, 0.09915, 0.101, 0.1027, 0.1045, 0.1062, 0.1079, 0.1096, 0.1112, 0.1129;
0.02712, 0.03321, 0.03833, 0.04286, 0.04695, 0.05072, 0.05422, 0.0575, 0.06062, 0.06357, 0.0664, 0.06913, 0.07174, 0.07424, 0.07668, 0.07904, 0.08134, 0.08356, 0.08572, 0.08784, 0.08993, 0.09195, 0.09392, 0.09584, 0.09775, 0.09961, 0.1014, 0.1032, 0.105, 0.1067, 0.1084, 0.1101, 0.1118, 0.1134;
0.02726, 0.03338, 0.03854, 0.04307, 0.04719, 0.05096, 0.05447, 0.05779, 0.06092, 0.06389, 0.06673, 0.06945, 0.07208, 0.07461, 0.07706, 0.07942, 0.08172, 0.08396, 0.08615, 0.08828, 0.09036, 0.0924, 0.09438, 0.09632, 0.09823, 0.1001, 0.1019, 0.1037, 0.1055, 0.1072, 0.109, 0.1107, 0.1123, 0.114;
0.02739, 0.03353, 0.03871, 0.0433, 0.04743, 0.05123, 0.05476, 0.05808, 0.06121, 0.06421, 0.06707, 0.06981, 0.07245, 0.07499, 0.07744, 0.07983, 0.08213, 0.0844, 0.08658, 0.08871, 0.09081, 0.09284, 0.09483, 0.09681, 0.09871, 0.1006, 0.1024, 0.1043, 0.106, 0.1078, 0.1095, 0.1112, 0.1129, 0.1145;
0.02753, 0.03371, 0.03891, 0.04353, 0.04767, 0.05149, 0.05504, 0.05838, 0.06154, 0.06453, 0.06742, 0.07017, 0.07282, 0.07538, 0.07784, 0.08023, 0.08256, 0.08482, 0.08703, 0.08918, 0.09128, 0.09332, 0.09533, 0.09729, 0.09923, 0.1011, 0.103, 0.1048, 0.1066, 0.1084, 0.1101, 0.1118, 0.1135, 0.1151;
0.02767, 0.03388, 0.03914, 0.04375, 0.04794, 0.05176, 0.05533, 0.05871, 0.06187, 0.06489, 0.06777, 0.07055, 0.07321, 0.07578, 0.07827, 0.08067, 0.083, 0.0853, 0.0875, 0.08965, 0.09176, 0.09382, 0.09585, 0.09783, 0.09976, 0.1017, 0.1035, 0.1054, 0.1072, 0.1089, 0.1107, 0.1124, 0.1141, 0.1158;
0.02783, 0.03407, 0.03936, 0.04398, 0.04821, 0.05206, 0.05565, 0.05901, 0.06222, 0.06524, 0.06814, 0.07094, 0.07362, 0.0762, 0.0787, 0.08113, 0.08347, 0.08576, 0.088, 0.09017, 0.09228, 0.09436, 0.09638, 0.09837, 0.1003, 0.1022, 0.1041, 0.106, 0.1078, 0.1096, 0.1113, 0.113, 0.1147, 0.1164;
0.02798, 0.03427, 0.03959, 0.04424, 0.04846, 0.05235, 0.05596, 0.05937, 0.06258, 0.06563, 0.06856, 0.07135, 0.07405, 0.07664, 0.07915, 0.08159, 0.08396, 0.08626, 0.0885, 0.09069, 0.09283, 0.0949, 0.09694, 0.09896, 0.1009, 0.1028, 0.1047, 0.1066, 0.1084, 0.1102, 0.1119, 0.1137, 0.1154, 0.1171;
0.02816, 0.0345, 0.03983, 0.04452, 0.04876, 0.05269, 0.05632, 0.05975, 0.06297, 0.06602, 0.06898, 0.07179, 0.07451, 0.07711, 0.07964, 0.08209, 0.08447, 0.0868, 0.08904, 0.09123, 0.09339, 0.09549, 0.09756, 0.09956, 0.1015, 0.1035, 0.1053, 0.1072, 0.1091, 0.1108, 0.1126, 0.1144, 0.1161, 0.1178;
0.02835, 0.03471, 0.04008, 0.04482, 0.04908, 0.05301, 0.05668, 0.06013, 0.06335, 0.06648, 0.06941, 0.07224, 0.07498, 0.0776, 0.08014, 0.08264, 0.08502, 0.08736, 0.08963, 0.09183, 0.09399, 0.09611, 0.09817, 0.1002, 0.1022, 0.1041, 0.106, 0.1079, 0.1097, 0.1116, 0.1134, 0.1151, 0.1169, 0.1185;
0.02856, 0.03494, 0.04035, 0.04511, 0.04943, 0.05338, 0.05708, 0.06054, 0.06382, 0.06692, 0.06988, 0.07274, 0.07551, 0.07815, 0.08071, 0.08318, 0.08561, 0.08796, 0.09023, 0.09246, 0.09462, 0.09675, 0.09883, 0.1009, 0.1029, 0.1048, 0.1068, 0.1087, 0.1105, 0.1124, 0.1141, 0.1159, 0.1176, 0.1194;
0.02873, 0.03519, 0.04066, 0.04544, 0.04979, 0.05379, 0.05749, 0.06099, 0.06428, 0.06742, 0.07042, 0.07328, 0.07604, 0.07871, 0.08128, 0.08381, 0.08621, 0.08861, 0.09088, 0.09312, 0.09532, 0.09747, 0.09956, 0.1016, 0.1036, 0.1056, 0.1075, 0.1094, 0.1113, 0.1131, 0.115, 0.1168, 0.1185, 0.1202;
0.02898, 0.03549, 0.04098, 0.04578, 0.05018, 0.0542, 0.05794, 0.06147, 0.06478, 0.06794, 0.07094, 0.07384, 0.07663, 0.07933, 0.08193, 0.08447, 0.08689, 0.0893, 0.09159, 0.09387, 0.09607, 0.09823, 0.1004, 0.1024, 0.1044, 0.1064, 0.1084, 0.1103, 0.1122, 0.1141, 0.1159, 0.1177, 0.1194, 0.1212;
0.02924, 0.03581, 0.04134, 0.04621, 0.05061, 0.05466, 0.05841, 0.06198, 0.06532, 0.06853, 0.07155, 0.07449, 0.07728, 0.08001, 0.08264, 0.08517, 0.08765, 0.09004, 0.09238, 0.09467, 0.09688, 0.09909, 0.1012, 0.1033, 0.1053, 0.1073, 0.1093, 0.1112, 0.1132, 0.115, 0.1169, 0.1187, 0.1205, 0.1222;
0.02952, 0.03612, 0.0417, 0.04663, 0.05109, 0.05517, 0.05898, 0.06255, 0.06593, 0.06917, 0.07224, 0.0752, 0.07803, 0.08076, 0.08343, 0.08599, 0.08846, 0.09091, 0.09327, 0.09555, 0.09781, 0.09999, 0.1022, 0.1043, 0.1063, 0.1084, 0.1103, 0.1123, 0.1142, 0.1161, 0.118, 0.1198, 0.1216, 0.1234;
0.0298, 0.03652, 0.04217, 0.04711, 0.0516, 0.05573, 0.05963, 0.06321, 0.06663, 0.06991, 0.07301, 0.07599, 0.07884, 0.08162, 0.08429, 0.08689, 0.0894, 0.09184, 0.09423, 0.09657, 0.09882, 0.1011, 0.1032, 0.1054, 0.1074, 0.1095, 0.1115, 0.1135, 0.1154, 0.1173, 0.1192, 0.121, 0.1229, 0.1247;
0.03016, 0.03698, 0.04267, 0.0477, 0.05224, 0.05644, 0.06034, 0.064, 0.06744, 0.07072, 0.07387, 0.07692, 0.0798, 0.0826, 0.08534, 0.08796, 0.09051, 0.09296, 0.09539, 0.09773, 0.1001, 0.1023, 0.1045, 0.1067, 0.1087, 0.1108, 0.1129, 0.1148, 0.1168, 0.1187, 0.1207, 0.1225, 0.1244, 0.1262;
0.03062, 0.03747, 0.04325, 0.04842, 0.05298, 0.05724, 0.06121, 0.06493, 0.06841, 0.07178, 0.07494, 0.07801, 0.08099, 0.08379, 0.08656, 0.08921, 0.09179, 0.09431, 0.09676, 0.09916, 0.1015, 0.1038, 0.106, 0.1082, 0.1103, 0.1125, 0.1145, 0.1165, 0.1185, 0.1205, 0.1224, 0.1243, 0.1262, 0.128;
0.03117, 0.03821, 0.04409, 0.04927, 0.05398, 0.05827, 0.06232, 0.06609, 0.06966, 0.07311, 0.07633, 0.07945, 0.08247, 0.08535, 0.08814, 0.09086, 0.0935, 0.09602, 0.09853, 0.101, 0.1034, 0.1057, 0.1079, 0.1102, 0.1124, 0.1145, 0.1166, 0.1187, 0.1207, 0.1227, 0.1247, 0.1266, 0.1285, 0.1303;
];
[X, Y] = meshgrid(dP, PressureInlet);
Z = values;
surf(X, Y, Z)
xlabel('\Delta Pressure')
ylabel('Pressure at Inlet')
zlabel('values')
Torsten
Torsten 2024 年 10 月 15 日
編集済み: Torsten 2024 年 10 月 15 日
Thank you for your support. What actually you are trying to do in here? create an array? if yes, what is the reason of multiplying to 34?
for i = 1:31
for j = 1:34
X((i-1)*34+j) = PressureInlet(i);
Y((i-1)*34+j) = dP(j);
Z((i-1)*34+j) = values(i,j);
end
end
I did the same as "meshgrid" does because I didn't trust in the order of the elements in X, Y and Z in your code (right so as you can see from the results).
31 is the number of elements of "PressureInlet", 34 is the number of elements of "dP".
Andrei
Andrei 2024 年 10 月 15 日
Thanks, figured out. i saw on the workspace widnow creating these 3 new variables with total number of values. I also, observed in there that MATLAB is rounding the values from original array.
Fo example for 42 & 2 i have a volumetric flow of 0.02568 and software rounds it up to 0.0257.
Is it possible to keep the 5 decimal point?
Torsten
Torsten 2024 年 10 月 15 日
Internally, MATLAB keeps all decimal places. The rounding is only for output purposes.
Use
format long
if you want to see all decimals.
Andrei
Andrei 2024 年 10 月 15 日
Thank you Torsten, it is very helpful. I hope you could guide me in the right direction. valve itself has an operational range and at some pressure inlets the valve will not be able to work on a pressure drop of 35 Bar or 1 Bar. Is there a way to tell the software to ignore some areas?
dP = [2, 3, 4, 5];
PressureInlet = [8, 9, 10, 11];
values = [
0.01597, 0, 0, 0;
0.01605, 0.02271, 0, 0;
0.01613, 0.02282, 0.02795, 0;
0.016210,0.02293,0.02808,0.03242;
];
Torsten
Torsten 2024 年 10 月 15 日
編集済み: Torsten 2024 年 10 月 15 日
After building X, Y and Z, just remove the data points from these vectors that are unphysical and then do the fitting without these points.
for i = 1:numel(X)
if X(i) ... & Y(i) ...
X(i) = [];
Y(i) = [];
Z(i) = [];
end
end
% Fit a 2D polynomial surface of degree 3 (example)
ft = fittype('poly33'); % poly33 degree of the for the x terms and degree of three for the y terms
f = fit([X(:), Y(:)], Z(:), ft);
Andrei
Andrei 2025 年 4 月 11 日
Hi Torsten, it doesn't seem to work. i don't want to have x and y blank, because only few z - values would need to be zero

サインインしてコメントする。

Sam Chak
Sam Chak 2024 年 10 月 15 日

0 投票

I believe the correct syntax should be [X, Y] = meshgrid(dP, PressureInlet), and the remainder of your code appears to be functioning correctly. Additionally, the goodness-of-fit statistics indicate that the selected 'poly33' model is a good fit.
%% Data preparation
dP = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35];
PressureInlet = [42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72];
values = [
0.02568, 0.03147, 0.03633, 0.04062, 0.0445, 0.04807, 0.05138, 0.05451, 0.05745, 0.06026, 0.06292, 0.06549, 0.06797, 0.07036, 0.07267, 0.0749, 0.07708, 0.07918, 0.08124, 0.08325, 0.08521, 0.08713, 0.08899, 0.09083, 0.09264, 0.09439, 0.09613, 0.09782, 0.0995, 0.1012, 0.1028, 0.1044, 0.1059, 0.1075;
0.02579, 0.03159, 0.03647, 0.04078, 0.04466, 0.04825, 0.05157, 0.0547, 0.05766, 0.06048, 0.06316, 0.06574, 0.06823, 0.07062, 0.07294, 0.07519, 0.07737, 0.07949, 0.08155, 0.08355, 0.08553, 0.08745, 0.08933, 0.09116, 0.09298, 0.09475, 0.09648, 0.09819, 0.09986, 0.1015, 0.1031, 0.1048, 0.1063, 0.1079;
0.02588, 0.03171, 0.0366, 0.04092, 0.04483, 0.04843, 0.05178, 0.05491, 0.05788, 0.06071, 0.0634, 0.06599, 0.06849, 0.07089, 0.07322, 0.07546, 0.07766, 0.07977, 0.08186, 0.08387, 0.08584, 0.08778, 0.08968, 0.09151, 0.09332, 0.0951, 0.09686, 0.09857, 0.1003, 0.1019, 0.1035, 0.1052, 0.1067, 0.1083;
0.02598, 0.03183, 0.03675, 0.04108, 0.045, 0.04862, 0.05198, 0.05511, 0.0581, 0.06095, 0.06365, 0.06624, 0.06875, 0.07116, 0.0735, 0.07575, 0.07796, 0.08009, 0.08216, 0.08421, 0.08618, 0.08812, 0.09002, 0.09187, 0.09368, 0.09547, 0.09722, 0.09894, 0.1006, 0.1023, 0.1039, 0.1055, 0.1071, 0.1087;
0.02608, 0.03195, 0.03689, 0.04125, 0.04519, 0.04881, 0.05218, 0.05534, 0.05832, 0.06117, 0.0639, 0.0665, 0.06902, 0.07143, 0.07377, 0.07606, 0.07826, 0.08041, 0.0825, 0.08453, 0.08651, 0.08846, 0.09036, 0.09223, 0.09406, 0.09584, 0.0976, 0.09933, 0.101, 0.1027, 0.1043, 0.106, 0.1076, 0.1091;
0.02619, 0.03208, 0.03703, 0.04141, 0.04535, 0.04898, 0.05238, 0.05555, 0.05855, 0.06141, 0.06414, 0.06677, 0.0693, 0.07173, 0.07408, 0.07636, 0.07856, 0.08072, 0.08282, 0.08487, 0.08686, 0.08881, 0.09071, 0.09259, 0.09443, 0.09623, 0.09799, 0.09972, 0.1014, 0.1031, 0.1048, 0.1064, 0.108, 0.1096;
0.02629, 0.03219, 0.03719, 0.04157, 0.04554, 0.04919, 0.0526, 0.05577, 0.05879, 0.06167, 0.06441, 0.06703, 0.06956, 0.072, 0.07437, 0.07665, 0.07887, 0.08105, 0.08314, 0.0852, 0.08722, 0.08916, 0.09109, 0.09296, 0.09481, 0.0966, 0.09837, 0.1001, 0.1018, 0.1035, 0.1052, 0.1068, 0.1084, 0.11;
0.02639, 0.03233, 0.03734, 0.04174, 0.04573, 0.0494, 0.0528, 0.056, 0.05904, 0.06192, 0.06467, 0.0673, 0.06986, 0.0723, 0.07467, 0.07698, 0.07922, 0.08137, 0.0835, 0.08554, 0.08757, 0.08954, 0.09145, 0.09333, 0.09518, 0.097, 0.09879, 0.1005, 0.1022, 0.1039, 0.1056, 0.1073, 0.1089, 0.1105;
0.0265, 0.03248, 0.0375, 0.04191, 0.04591, 0.0496, 0.05303, 0.05623, 0.05928, 0.06217, 0.06494, 0.06758, 0.07015, 0.0726, 0.07499, 0.0773, 0.07953, 0.08172, 0.08384, 0.0859, 0.08792, 0.0899, 0.09184, 0.09373, 0.09558, 0.09742, 0.09921, 0.1009, 0.1027, 0.1044, 0.1061, 0.1077, 0.1093, 0.1109;
0.02662, 0.03261, 0.03764, 0.0421, 0.04612, 0.04981, 0.05325, 0.05648, 0.05953, 0.06244, 0.06523, 0.06788, 0.07045, 0.0729, 0.0753, 0.07763, 0.07989, 0.08207, 0.08419, 0.08628, 0.08829, 0.09028, 0.09223, 0.09412, 0.096, 0.09782, 0.09963, 0.1014, 0.1031, 0.1048, 0.1065, 0.1082, 0.1098, 0.1114;
0.02674, 0.03275, 0.03782, 0.04229, 0.04633, 0.05003, 0.05349, 0.05672, 0.0598, 0.0627, 0.0655, 0.06817, 0.07075, 0.07323, 0.07563, 0.07796, 0.08021, 0.08242, 0.08455, 0.08664, 0.08869, 0.09069, 0.09262, 0.09455, 0.0964, 0.09825, 0.1001, 0.1018, 0.1036, 0.1053, 0.107, 0.1086, 0.1103, 0.1119;
0.02687, 0.0329, 0.03798, 0.04248, 0.04652, 0.05024, 0.05371, 0.05698, 0.06005, 0.06301, 0.0658, 0.06847, 0.07107, 0.07355, 0.07598, 0.07831, 0.08059, 0.08279, 0.08494, 0.08705, 0.08908, 0.09109, 0.09304, 0.09497, 0.09684, 0.09869, 0.1005, 0.1023, 0.104, 0.1058, 0.1074, 0.1091, 0.1108, 0.1124;
0.02699, 0.03304, 0.03816, 0.04268, 0.04675, 0.05047, 0.05398, 0.05723, 0.06033, 0.06328, 0.06608, 0.0688, 0.0714, 0.0739, 0.07633, 0.07866, 0.08096, 0.08316, 0.08533, 0.08743, 0.0895, 0.0915, 0.09349, 0.0954, 0.0973, 0.09915, 0.101, 0.1027, 0.1045, 0.1062, 0.1079, 0.1096, 0.1112, 0.1129;
0.02712, 0.03321, 0.03833, 0.04286, 0.04695, 0.05072, 0.05422, 0.0575, 0.06062, 0.06357, 0.0664, 0.06913, 0.07174, 0.07424, 0.07668, 0.07904, 0.08134, 0.08356, 0.08572, 0.08784, 0.08993, 0.09195, 0.09392, 0.09584, 0.09775, 0.09961, 0.1014, 0.1032, 0.105, 0.1067, 0.1084, 0.1101, 0.1118, 0.1134;
0.02726, 0.03338, 0.03854, 0.04307, 0.04719, 0.05096, 0.05447, 0.05779, 0.06092, 0.06389, 0.06673, 0.06945, 0.07208, 0.07461, 0.07706, 0.07942, 0.08172, 0.08396, 0.08615, 0.08828, 0.09036, 0.0924, 0.09438, 0.09632, 0.09823, 0.1001, 0.1019, 0.1037, 0.1055, 0.1072, 0.109, 0.1107, 0.1123, 0.114;
0.02739, 0.03353, 0.03871, 0.0433, 0.04743, 0.05123, 0.05476, 0.05808, 0.06121, 0.06421, 0.06707, 0.06981, 0.07245, 0.07499, 0.07744, 0.07983, 0.08213, 0.0844, 0.08658, 0.08871, 0.09081, 0.09284, 0.09483, 0.09681, 0.09871, 0.1006, 0.1024, 0.1043, 0.106, 0.1078, 0.1095, 0.1112, 0.1129, 0.1145;
0.02753, 0.03371, 0.03891, 0.04353, 0.04767, 0.05149, 0.05504, 0.05838, 0.06154, 0.06453, 0.06742, 0.07017, 0.07282, 0.07538, 0.07784, 0.08023, 0.08256, 0.08482, 0.08703, 0.08918, 0.09128, 0.09332, 0.09533, 0.09729, 0.09923, 0.1011, 0.103, 0.1048, 0.1066, 0.1084, 0.1101, 0.1118, 0.1135, 0.1151;
0.02767, 0.03388, 0.03914, 0.04375, 0.04794, 0.05176, 0.05533, 0.05871, 0.06187, 0.06489, 0.06777, 0.07055, 0.07321, 0.07578, 0.07827, 0.08067, 0.083, 0.0853, 0.0875, 0.08965, 0.09176, 0.09382, 0.09585, 0.09783, 0.09976, 0.1017, 0.1035, 0.1054, 0.1072, 0.1089, 0.1107, 0.1124, 0.1141, 0.1158;
0.02783, 0.03407, 0.03936, 0.04398, 0.04821, 0.05206, 0.05565, 0.05901, 0.06222, 0.06524, 0.06814, 0.07094, 0.07362, 0.0762, 0.0787, 0.08113, 0.08347, 0.08576, 0.088, 0.09017, 0.09228, 0.09436, 0.09638, 0.09837, 0.1003, 0.1022, 0.1041, 0.106, 0.1078, 0.1096, 0.1113, 0.113, 0.1147, 0.1164;
0.02798, 0.03427, 0.03959, 0.04424, 0.04846, 0.05235, 0.05596, 0.05937, 0.06258, 0.06563, 0.06856, 0.07135, 0.07405, 0.07664, 0.07915, 0.08159, 0.08396, 0.08626, 0.0885, 0.09069, 0.09283, 0.0949, 0.09694, 0.09896, 0.1009, 0.1028, 0.1047, 0.1066, 0.1084, 0.1102, 0.1119, 0.1137, 0.1154, 0.1171;
0.02816, 0.0345, 0.03983, 0.04452, 0.04876, 0.05269, 0.05632, 0.05975, 0.06297, 0.06602, 0.06898, 0.07179, 0.07451, 0.07711, 0.07964, 0.08209, 0.08447, 0.0868, 0.08904, 0.09123, 0.09339, 0.09549, 0.09756, 0.09956, 0.1015, 0.1035, 0.1053, 0.1072, 0.1091, 0.1108, 0.1126, 0.1144, 0.1161, 0.1178;
0.02835, 0.03471, 0.04008, 0.04482, 0.04908, 0.05301, 0.05668, 0.06013, 0.06335, 0.06648, 0.06941, 0.07224, 0.07498, 0.0776, 0.08014, 0.08264, 0.08502, 0.08736, 0.08963, 0.09183, 0.09399, 0.09611, 0.09817, 0.1002, 0.1022, 0.1041, 0.106, 0.1079, 0.1097, 0.1116, 0.1134, 0.1151, 0.1169, 0.1185;
0.02856, 0.03494, 0.04035, 0.04511, 0.04943, 0.05338, 0.05708, 0.06054, 0.06382, 0.06692, 0.06988, 0.07274, 0.07551, 0.07815, 0.08071, 0.08318, 0.08561, 0.08796, 0.09023, 0.09246, 0.09462, 0.09675, 0.09883, 0.1009, 0.1029, 0.1048, 0.1068, 0.1087, 0.1105, 0.1124, 0.1141, 0.1159, 0.1176, 0.1194;
0.02873, 0.03519, 0.04066, 0.04544, 0.04979, 0.05379, 0.05749, 0.06099, 0.06428, 0.06742, 0.07042, 0.07328, 0.07604, 0.07871, 0.08128, 0.08381, 0.08621, 0.08861, 0.09088, 0.09312, 0.09532, 0.09747, 0.09956, 0.1016, 0.1036, 0.1056, 0.1075, 0.1094, 0.1113, 0.1131, 0.115, 0.1168, 0.1185, 0.1202;
0.02898, 0.03549, 0.04098, 0.04578, 0.05018, 0.0542, 0.05794, 0.06147, 0.06478, 0.06794, 0.07094, 0.07384, 0.07663, 0.07933, 0.08193, 0.08447, 0.08689, 0.0893, 0.09159, 0.09387, 0.09607, 0.09823, 0.1004, 0.1024, 0.1044, 0.1064, 0.1084, 0.1103, 0.1122, 0.1141, 0.1159, 0.1177, 0.1194, 0.1212;
0.02924, 0.03581, 0.04134, 0.04621, 0.05061, 0.05466, 0.05841, 0.06198, 0.06532, 0.06853, 0.07155, 0.07449, 0.07728, 0.08001, 0.08264, 0.08517, 0.08765, 0.09004, 0.09238, 0.09467, 0.09688, 0.09909, 0.1012, 0.1033, 0.1053, 0.1073, 0.1093, 0.1112, 0.1132, 0.115, 0.1169, 0.1187, 0.1205, 0.1222;
0.02952, 0.03612, 0.0417, 0.04663, 0.05109, 0.05517, 0.05898, 0.06255, 0.06593, 0.06917, 0.07224, 0.0752, 0.07803, 0.08076, 0.08343, 0.08599, 0.08846, 0.09091, 0.09327, 0.09555, 0.09781, 0.09999, 0.1022, 0.1043, 0.1063, 0.1084, 0.1103, 0.1123, 0.1142, 0.1161, 0.118, 0.1198, 0.1216, 0.1234;
0.0298, 0.03652, 0.04217, 0.04711, 0.0516, 0.05573, 0.05963, 0.06321, 0.06663, 0.06991, 0.07301, 0.07599, 0.07884, 0.08162, 0.08429, 0.08689, 0.0894, 0.09184, 0.09423, 0.09657, 0.09882, 0.1011, 0.1032, 0.1054, 0.1074, 0.1095, 0.1115, 0.1135, 0.1154, 0.1173, 0.1192, 0.121, 0.1229, 0.1247;
0.03016, 0.03698, 0.04267, 0.0477, 0.05224, 0.05644, 0.06034, 0.064, 0.06744, 0.07072, 0.07387, 0.07692, 0.0798, 0.0826, 0.08534, 0.08796, 0.09051, 0.09296, 0.09539, 0.09773, 0.1001, 0.1023, 0.1045, 0.1067, 0.1087, 0.1108, 0.1129, 0.1148, 0.1168, 0.1187, 0.1207, 0.1225, 0.1244, 0.1262;
0.03062, 0.03747, 0.04325, 0.04842, 0.05298, 0.05724, 0.06121, 0.06493, 0.06841, 0.07178, 0.07494, 0.07801, 0.08099, 0.08379, 0.08656, 0.08921, 0.09179, 0.09431, 0.09676, 0.09916, 0.1015, 0.1038, 0.106, 0.1082, 0.1103, 0.1125, 0.1145, 0.1165, 0.1185, 0.1205, 0.1224, 0.1243, 0.1262, 0.128;
0.03117, 0.03821, 0.04409, 0.04927, 0.05398, 0.05827, 0.06232, 0.06609, 0.06966, 0.07311, 0.07633, 0.07945, 0.08247, 0.08535, 0.08814, 0.09086, 0.0935, 0.09602, 0.09853, 0.101, 0.1034, 0.1057, 0.1079, 0.1102, 0.1124, 0.1145, 0.1166, 0.1187, 0.1207, 0.1227, 0.1247, 0.1266, 0.1285, 0.1303;
];
%% Perform surface fitting
[X, Y] = meshgrid(dP, PressureInlet);
Z = values;
[sf, gof] = fit([X(:), Y(:)], Z(:), 'poly33')
sf =
Linear model Poly33: sf(x,y) = p00 + p10*x + p01*y + p20*x^2 + p11*x*y + p02*y^2 + p30*x^3 + p21*x^2*y + p12*x*y^2 + p03*y^3 Coefficients (with 95% confidence bounds): p00 = -0.07849 (-0.08929, -0.06769) p10 = 0.005251 (0.005072, 0.005429) p01 = 0.005311 (0.00474, 0.005882) p20 = -0.0001141 (-0.0001176, -0.0001106) p11 = -2.008e-05 (-2.562e-05, -1.453e-05) p02 = -9.757e-05 (-0.0001076, -8.755e-05) p30 = 1.541e-06 (1.497e-06, 1.585e-06) p21 = -2.503e-07 (-2.926e-07, -2.079e-07) p12 = 3.848e-07 (3.383e-07, 4.313e-07) p03 = 6.018e-07 (5.435e-07, 6.601e-07)
gof = struct with fields:
sse: 3.0362e-04 rsquare: 0.9995 dfe: 1044 adjrsquare: 0.9995 rmse: 5.3928e-04
%% Plot result
plot(sf, [X(:), Y(:)], Z(:))
xlabel('\Delta Pressure')
ylabel('Pressure at Inlet')
zlabel('values')
%% Prediction
new_dP = 6;
new_PressureInlet = 55;
new_value = feval(sf, [new_dP, new_PressureInlet])
new_value = 0.0462

カテゴリ

ヘルプ センター および File ExchangeGet Started with Curve Fitting Toolbox についてさらに検索

製品

タグ

質問済み:

2024 年 10 月 14 日

編集済み:

2025 年 4 月 11 日

Community Treasure Hunt

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

Start Hunting!

Translated by