Azzera filtri
Azzera filtri

Interpolating for multiple curves and finding the y axis value

4 visualizzazioni (ultimi 30 giorni)
How do I interpolate the x (angle) and A factor datapoints between multiple curves?
Each curve is for the different A factor. How to find out the coefficient value for an angle (x-axis) and specific curve (e.g., for A = 0.63).
The data is below:
x = [0 7.1702 9.1995 9.5716 11.3641 12.0744 12.5141 13.1736 13.4104 13.867 14.7294 15.1015 16.9448 17.0631 17.2322 18.3484 19.0079 20.0395 20.699 20.885 21.9673 22.4408 23.1342 24.2334 24.2672 25.3495 25.3664 26.9053 27.6494 28.3427 28.6302 28.867 31.336 31.8095 32.5197 32.6043 32.6212 35.5418 35.7159 36.1218 36.3078 38.1838 40.0113 40.7892 40.9583 41.401 41.9053 44.1496 44.425 45.2706 45.575 46.6573 46.8129 48.7542 49.3461 49.4549 49.4983 51.9051 52.1702 52.6082 52.7452 53.1172 53.4047 56.1781 57.4295 57.6325 57.7678 59.1375];
y1 = [0 0.0020385 0.0029971 0.0031692 0.0039805 0.0043153 0.0045343 0.0048942 0.0050347 0.0053227 0.0058919 0.0061278 0.0073044 0.0073855 0.0075032 0.0083247 0.0088284 0.0096041 0.0100713 0.0102005 0.010981 0.0113609 0.0119703 0.0130149 0.0130479 0.0141152 0.0141319 0.0156525 0.0163877 0.0170739 0.0173591 0.0175943 0.0201634 0.0206939 0.0215118 0.0216106 0.0216304 0.0251692 0.0253869 0.0258977 0.0261335 0.0285498 0.0309047 0.0319193 0.032142 0.03273 0.0334105 0.036545 0.0369321 0.0381116 0.0385328 0.0400127 0.040223 0.0428361 0.0436564 0.0438095 0.0438708 0.0473963 0.0477901 0.0484244 0.0485977 0.0491639 0.0495916 0.0537516 0.0556341 0.0559395 0.0561431 0.0582054];
y2 = [0 0.0012683 0.0021179 0.0022702 0.0030119 0.0033161 0.0035092 0.0038069 0.0039163 0.0041315 0.0045528 0.0047406 0.0057299 0.0057969 0.0058935 0.0065504 0.0069509 0.0075884 0.0079984 0.0081139 0.0087828 0.0090767 0.009513 0.0102275 0.0102501 0.0109859 0.0109976 0.0120843 0.0126222 0.0131294 0.0133411 0.0135161 0.0153693 0.0157302 0.0162751 0.0163402 0.0163533 0.0186568 0.0187971 0.0191247 0.0192751 0.0208039 0.0223233 0.0229833 0.0231281 0.0235096 0.0239475 0.0259189 0.0261606 0.0268967 0.027159 0.0280794 0.0282105 0.0298293 0.0303207 0.0304111 0.0304473 0.0324635 0.0326876 0.0330586 0.0331748 0.0334911 0.0337359 0.0361113 0.0371869 0.0373614 0.0374777 0.0386548];
y3 = [0 0.0006766 0.0012771 0.0013806 0.0018907 0.0021204 0.002306 0.0026193 0.0027171 0.0028934 0.0032128 0.0033498 0.0040542 0.0041021 0.0041712 0.0046468 0.0049396 0.0054045 0.0056995 0.0057817 0.0062531 0.006458 0.0067599 0.0072545 0.0072702 0.0077953 0.0078038 0.0085914 0.008973 0.0093259 0.0094717 0.0095916 0.0108428 0.0110848 0.0114515 0.0114956 0.0115044 0.0131414 0.0132431 0.0134797 0.0135881 0.01468 0.0157464 0.0162024 0.0163018 0.0165625 0.0168602 0.0181916 0.018355 0.0188555 0.0190349 0.0196682 0.0197587 0.0208751 0.0212111 0.0212726 0.0212972 0.0226611 0.0228141 0.0230691 0.0231495 0.0233696 0.0235414 0.0252623 0.026059 0.0261885 0.0262749 0.0271481];
y4 = [0 0.0001386 0.0003101 0.0003914 0.0007895 0.0009534 0.0010573 0.0012172 0.0012758 0.0013909 0.001615 0.0017137 0.0022114 0.0022435 0.0022893 0.0025888 0.0027614 0.0030217 0.0031838 0.0032293 0.0034972 0.0036189 0.0038069 0.0041348 0.0041454 0.0044929 0.0044984 0.0049984 0.0052326 0.005448 0.0055372 0.0056109 0.0064064 0.0065684 0.0068176 0.0068478 0.0068538 0.0079593 0.0080295 0.0081951 0.0082722 0.0090844 0.0098947 0.0102295 0.0103015 0.0104889 0.010701 0.0116406 0.0117567 0.0121153 0.0122452 0.0127101 0.0127772 0.0136188 0.013876 0.0139232 0.0139421 0.0149886 0.015104 0.0152948 0.0153545 0.0155167 0.015642 0.0168527 0.0173993 0.017488 0.0175471 0.0181454];
y5 = [0 1.00E-04 0.00022 0.0002489 0.0003969 0.0004566 0.0004931 0.0005463 0.0005648 0.0005992 0.0006584 0.0006806 0.0007686 0.0007744 0.0007831 0.0008563 0.0009153 0.0010211 0.0010907 0.00111 0.0012128 0.0012502 0.0012988 0.0013787 0.0013815 0.0014949 0.0014972 0.0017449 0.0018736 0.0019831 0.0020233 0.0020536 0.0022654 0.0023013 0.0023648 0.0023736 0.0023754 0.0028436 0.0028757 0.0029503 0.0029842 0.0033201 0.0036535 0.0038019 0.0038349 0.0039231 0.004027 0.0045444 0.0046125 0.0048235 0.0048992 0.0051622 0.0051989 0.0056406 0.005772 0.0057961 0.0058057 0.0063438 0.0064049 0.0065075 0.00654 0.0066292 0.006699 0.0073962 0.0076961 0.0077429 0.0077739 0.0080807];
figure
plot(x, y1); hold on
plot(x, y2); hold on
plot(x, y3); hold on
plot(x, y4); hold on
plot(x, y5); hold on
plot(40, 0.02, 'bp') % example for angle = 40 and A = 0.63
legend('A = 0.5', 'A = 0.6','A = 0.7','A = 0.8','A = 0.9')
title('Coefficient')
ylabel('K_c')
xlabel('angle')

Risposta accettata

Stephen23
Stephen23 il 22 Mag 2024
Modificato: Stephen23 il 22 Mag 2024
Forget about having lots of separate variables in the workspace. Learn to use matrices!
x = [0,7.1702,9.1995,9.5716,11.3641,12.0744,12.5141,13.1736,13.4104,13.867,14.7294,15.1015,16.9448,17.0631,17.2322,18.3484,19.0079,20.0395,20.699,20.885,21.9673,22.4408,23.1342,24.2334,24.2672,25.3495,25.3664,26.9053,27.6494,28.3427,28.6302,28.867,31.336,31.8095,32.5197,32.6043,32.6212,35.5418,35.7159,36.1218,36.3078,38.1838,40.0113,40.7892,40.9583,41.401,41.9053,44.1496,44.425,45.2706,45.575,46.6573,46.8129,48.7542,49.3461,49.4549,49.4983,51.9051,52.1702,52.6082,52.7452,53.1172,53.4047,56.1781,57.4295,57.6325,57.7678,59.1375];
y1 = [0,0.0020385,0.0029971,0.0031692,0.0039805,0.0043153,0.0045343,0.0048942,0.0050347,0.0053227,0.0058919,0.0061278,0.0073044,0.0073855,0.0075032,0.0083247,0.0088284,0.0096041,0.0100713,0.0102005,0.010981,0.0113609,0.0119703,0.0130149,0.0130479,0.0141152,0.0141319,0.0156525,0.0163877,0.0170739,0.0173591,0.0175943,0.0201634,0.0206939,0.0215118,0.0216106,0.0216304,0.0251692,0.0253869,0.0258977,0.0261335,0.0285498,0.0309047,0.0319193,0.032142,0.03273,0.0334105,0.036545,0.0369321,0.0381116,0.0385328,0.0400127,0.040223,0.0428361,0.0436564,0.0438095,0.0438708,0.0473963,0.0477901,0.0484244,0.0485977,0.0491639,0.0495916,0.0537516,0.0556341,0.0559395,0.0561431,0.0582054];
y2 = [0,0.0012683,0.0021179,0.0022702,0.0030119,0.0033161,0.0035092,0.0038069,0.0039163,0.0041315,0.0045528,0.0047406,0.0057299,0.0057969,0.0058935,0.0065504,0.0069509,0.0075884,0.0079984,0.0081139,0.0087828,0.0090767,0.009513,0.0102275,0.0102501,0.0109859,0.0109976,0.0120843,0.0126222,0.0131294,0.0133411,0.0135161,0.0153693,0.0157302,0.0162751,0.0163402,0.0163533,0.0186568,0.0187971,0.0191247,0.0192751,0.0208039,0.0223233,0.0229833,0.0231281,0.0235096,0.0239475,0.0259189,0.0261606,0.0268967,0.027159,0.0280794,0.0282105,0.0298293,0.0303207,0.0304111,0.0304473,0.0324635,0.0326876,0.0330586,0.0331748,0.0334911,0.0337359,0.0361113,0.0371869,0.0373614,0.0374777,0.0386548];
y3 = [0,0.0006766,0.0012771,0.0013806,0.0018907,0.0021204,0.002306,0.0026193,0.0027171,0.0028934,0.0032128,0.0033498,0.0040542,0.0041021,0.0041712,0.0046468,0.0049396,0.0054045,0.0056995,0.0057817,0.0062531,0.006458,0.0067599,0.0072545,0.0072702,0.0077953,0.0078038,0.0085914,0.008973,0.0093259,0.0094717,0.0095916,0.0108428,0.0110848,0.0114515,0.0114956,0.0115044,0.0131414,0.0132431,0.0134797,0.0135881,0.01468,0.0157464,0.0162024,0.0163018,0.0165625,0.0168602,0.0181916,0.018355,0.0188555,0.0190349,0.0196682,0.0197587,0.0208751,0.0212111,0.0212726,0.0212972,0.0226611,0.0228141,0.0230691,0.0231495,0.0233696,0.0235414,0.0252623,0.026059,0.0261885,0.0262749,0.0271481];
y4 = [0,0.0001386,0.0003101,0.0003914,0.0007895,0.0009534,0.0010573,0.0012172,0.0012758,0.0013909,0.001615,0.0017137,0.0022114,0.0022435,0.0022893,0.0025888,0.0027614,0.0030217,0.0031838,0.0032293,0.0034972,0.0036189,0.0038069,0.0041348,0.0041454,0.0044929,0.0044984,0.0049984,0.0052326,0.005448,0.0055372,0.0056109,0.0064064,0.0065684,0.0068176,0.0068478,0.0068538,0.0079593,0.0080295,0.0081951,0.0082722,0.0090844,0.0098947,0.0102295,0.0103015,0.0104889,0.010701,0.0116406,0.0117567,0.0121153,0.0122452,0.0127101,0.0127772,0.0136188,0.013876,0.0139232,0.0139421,0.0149886,0.015104,0.0152948,0.0153545,0.0155167,0.015642,0.0168527,0.0173993,0.017488,0.0175471,0.0181454];
y5 = [0,1.00E-04,0.00022,0.0002489,0.0003969,0.0004566,0.0004931,0.0005463,0.0005648,0.0005992,0.0006584,0.0006806,0.0007686,0.0007744,0.0007831,0.0008563,0.0009153,0.0010211,0.0010907,0.00111,0.0012128,0.0012502,0.0012988,0.0013787,0.0013815,0.0014949,0.0014972,0.0017449,0.0018736,0.0019831,0.0020233,0.0020536,0.0022654,0.0023013,0.0023648,0.0023736,0.0023754,0.0028436,0.0028757,0.0029503,0.0029842,0.0033201,0.0036535,0.0038019,0.0038349,0.0039231,0.004027,0.0045444,0.0046125,0.0048235,0.0048992,0.0051622,0.0051989,0.0056406,0.005772,0.0057961,0.0058057,0.0063438,0.0064049,0.0065075,0.00654,0.0066292,0.006699,0.0073962,0.0076961,0.0077429,0.0077739,0.0080807];
y = [y1(:),y2(:),y3(:),y4(:),y5(:)]; % much better!
A = [0.5;0.6;0.7;0.8;0.9];
C = compose("A = %g",A);
plot(x,y)
hold on
% example for angle = 40 and A = 0.63
yq = interp2(A,x,y,0.63,40)
yq = 0.0203
plot(40,yq,'*k')
legend(C{:},'A = 0.63')

Più risposte (1)

Voss
Voss il 22 Mag 2024
x = [0 7.1702 9.1995 9.5716 11.3641 12.0744 12.5141 13.1736 13.4104 13.867 14.7294 15.1015 16.9448 17.0631 17.2322 18.3484 19.0079 20.0395 20.699 20.885 21.9673 22.4408 23.1342 24.2334 24.2672 25.3495 25.3664 26.9053 27.6494 28.3427 28.6302 28.867 31.336 31.8095 32.5197 32.6043 32.6212 35.5418 35.7159 36.1218 36.3078 38.1838 40.0113 40.7892 40.9583 41.401 41.9053 44.1496 44.425 45.2706 45.575 46.6573 46.8129 48.7542 49.3461 49.4549 49.4983 51.9051 52.1702 52.6082 52.7452 53.1172 53.4047 56.1781 57.4295 57.6325 57.7678 59.1375];
A = [0.5 0.6 0.7 0.8 0.9];
y1 = [0 0.0020385 0.0029971 0.0031692 0.0039805 0.0043153 0.0045343 0.0048942 0.0050347 0.0053227 0.0058919 0.0061278 0.0073044 0.0073855 0.0075032 0.0083247 0.0088284 0.0096041 0.0100713 0.0102005 0.010981 0.0113609 0.0119703 0.0130149 0.0130479 0.0141152 0.0141319 0.0156525 0.0163877 0.0170739 0.0173591 0.0175943 0.0201634 0.0206939 0.0215118 0.0216106 0.0216304 0.0251692 0.0253869 0.0258977 0.0261335 0.0285498 0.0309047 0.0319193 0.032142 0.03273 0.0334105 0.036545 0.0369321 0.0381116 0.0385328 0.0400127 0.040223 0.0428361 0.0436564 0.0438095 0.0438708 0.0473963 0.0477901 0.0484244 0.0485977 0.0491639 0.0495916 0.0537516 0.0556341 0.0559395 0.0561431 0.0582054];
y2 = [0 0.0012683 0.0021179 0.0022702 0.0030119 0.0033161 0.0035092 0.0038069 0.0039163 0.0041315 0.0045528 0.0047406 0.0057299 0.0057969 0.0058935 0.0065504 0.0069509 0.0075884 0.0079984 0.0081139 0.0087828 0.0090767 0.009513 0.0102275 0.0102501 0.0109859 0.0109976 0.0120843 0.0126222 0.0131294 0.0133411 0.0135161 0.0153693 0.0157302 0.0162751 0.0163402 0.0163533 0.0186568 0.0187971 0.0191247 0.0192751 0.0208039 0.0223233 0.0229833 0.0231281 0.0235096 0.0239475 0.0259189 0.0261606 0.0268967 0.027159 0.0280794 0.0282105 0.0298293 0.0303207 0.0304111 0.0304473 0.0324635 0.0326876 0.0330586 0.0331748 0.0334911 0.0337359 0.0361113 0.0371869 0.0373614 0.0374777 0.0386548];
y3 = [0 0.0006766 0.0012771 0.0013806 0.0018907 0.0021204 0.002306 0.0026193 0.0027171 0.0028934 0.0032128 0.0033498 0.0040542 0.0041021 0.0041712 0.0046468 0.0049396 0.0054045 0.0056995 0.0057817 0.0062531 0.006458 0.0067599 0.0072545 0.0072702 0.0077953 0.0078038 0.0085914 0.008973 0.0093259 0.0094717 0.0095916 0.0108428 0.0110848 0.0114515 0.0114956 0.0115044 0.0131414 0.0132431 0.0134797 0.0135881 0.01468 0.0157464 0.0162024 0.0163018 0.0165625 0.0168602 0.0181916 0.018355 0.0188555 0.0190349 0.0196682 0.0197587 0.0208751 0.0212111 0.0212726 0.0212972 0.0226611 0.0228141 0.0230691 0.0231495 0.0233696 0.0235414 0.0252623 0.026059 0.0261885 0.0262749 0.0271481];
y4 = [0 0.0001386 0.0003101 0.0003914 0.0007895 0.0009534 0.0010573 0.0012172 0.0012758 0.0013909 0.001615 0.0017137 0.0022114 0.0022435 0.0022893 0.0025888 0.0027614 0.0030217 0.0031838 0.0032293 0.0034972 0.0036189 0.0038069 0.0041348 0.0041454 0.0044929 0.0044984 0.0049984 0.0052326 0.005448 0.0055372 0.0056109 0.0064064 0.0065684 0.0068176 0.0068478 0.0068538 0.0079593 0.0080295 0.0081951 0.0082722 0.0090844 0.0098947 0.0102295 0.0103015 0.0104889 0.010701 0.0116406 0.0117567 0.0121153 0.0122452 0.0127101 0.0127772 0.0136188 0.013876 0.0139232 0.0139421 0.0149886 0.015104 0.0152948 0.0153545 0.0155167 0.015642 0.0168527 0.0173993 0.017488 0.0175471 0.0181454];
y5 = [0 1.00E-04 0.00022 0.0002489 0.0003969 0.0004566 0.0004931 0.0005463 0.0005648 0.0005992 0.0006584 0.0006806 0.0007686 0.0007744 0.0007831 0.0008563 0.0009153 0.0010211 0.0010907 0.00111 0.0012128 0.0012502 0.0012988 0.0013787 0.0013815 0.0014949 0.0014972 0.0017449 0.0018736 0.0019831 0.0020233 0.0020536 0.0022654 0.0023013 0.0023648 0.0023736 0.0023754 0.0028436 0.0028757 0.0029503 0.0029842 0.0033201 0.0036535 0.0038019 0.0038349 0.0039231 0.004027 0.0045444 0.0046125 0.0048235 0.0048992 0.0051622 0.0051989 0.0056406 0.005772 0.0057961 0.0058057 0.0063438 0.0064049 0.0065075 0.00654 0.0066292 0.006699 0.0073962 0.0076961 0.0077429 0.0077739 0.0080807];
y = [y1; y2; y3; y4; y5]
y = 5x68
0 0.0020 0.0030 0.0032 0.0040 0.0043 0.0045 0.0049 0.0050 0.0053 0.0059 0.0061 0.0073 0.0074 0.0075 0.0083 0.0088 0.0096 0.0101 0.0102 0.0110 0.0114 0.0120 0.0130 0.0130 0.0141 0.0141 0.0157 0.0164 0.0171 0 0.0013 0.0021 0.0023 0.0030 0.0033 0.0035 0.0038 0.0039 0.0041 0.0046 0.0047 0.0057 0.0058 0.0059 0.0066 0.0070 0.0076 0.0080 0.0081 0.0088 0.0091 0.0095 0.0102 0.0103 0.0110 0.0110 0.0121 0.0126 0.0131 0 0.0007 0.0013 0.0014 0.0019 0.0021 0.0023 0.0026 0.0027 0.0029 0.0032 0.0033 0.0041 0.0041 0.0042 0.0046 0.0049 0.0054 0.0057 0.0058 0.0063 0.0065 0.0068 0.0073 0.0073 0.0078 0.0078 0.0086 0.0090 0.0093 0 0.0001 0.0003 0.0004 0.0008 0.0010 0.0011 0.0012 0.0013 0.0014 0.0016 0.0017 0.0022 0.0022 0.0023 0.0026 0.0028 0.0030 0.0032 0.0032 0.0035 0.0036 0.0038 0.0041 0.0041 0.0045 0.0045 0.0050 0.0052 0.0054 0 0.0001 0.0002 0.0002 0.0004 0.0005 0.0005 0.0005 0.0006 0.0006 0.0007 0.0007 0.0008 0.0008 0.0008 0.0009 0.0009 0.0010 0.0011 0.0011 0.0012 0.0013 0.0013 0.0014 0.0014 0.0015 0.0015 0.0017 0.0019 0.0020
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
figure
plot(x, y.')
hold on
plot(40, 0.02, 'bo') % example for angle = 40 and A = 0.63
legend("A = "+A)
title('Coefficient')
ylabel('K_c')
xlabel('angle')
% query point:
xq = 40;
Aq = 0.63;
% interpolated y value:
yq = interp2(x,A,y,xq,Aq)
yq = 0.0203
plot(xq,yq,'rx','HandleVisibility','off') % 'HandleVisibility','off' to avoid showing in the legend

Categorie

Scopri di più su Dates and Time in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by