Lookup values in other table that has a range of values
4 次查看(过去 30 天)
显示 更早的评论
I've got two data sets from a drilling project collected by different sensors.
One table has rate of penetration at the recorded depths. The other has wireline gamma values for the same hole but at different recorded depths.
Rate of Penetration data set
holeid = [12;12;12;12;12;12;12;12;12;12;12;12;12;12;12;12];
depth = [0;0.0542;0.0801;0.2222;0.3959;0.4572;0.5110;0.5348;0.5712;0.6099;0.6437;0.6799;0.8011;0.8928;0.9590;1.0110];
rop = [118.7000;207.8000;139.6000;176.0000;177.8000;229.3000;242.4000;138.9000;85.7000;140.8000;164.5000;125.4000;189.8000;164.0000;118.4000;211.4000];
rophole12 = table(holeid,depth,rop);
Gamma data set
(e.g. depth from 0 to 0.13 is treated as from/to range and has gamma value of 1, depth of 0.13 to 0.22 has gamma value of 12, etc)
holeid1 = [12;12;12;12;12;12;12;12;12;12;12;12;12];
depth1 = [0;0.13;0.22;0.36;0.48;0.56;0.67;0.78;0.84;0.96;1.03;1.14;1.24;];
gamma1 = [1;12;34;23;42;12;43;67;111;200;153;188;55];
gammahole12 = table(holeid1,depth1,gamma1);
What's the best way to get the gamma values from gammahole12 at the depths specified in the rophole12 table e.g. gamma at 0, 0.0542, 0.0801, etc?
In excel, I've used the vlookup function with true. Is there a MATLAB equivalent or different way to lookup a value within a different table with approximate reference, e.g. depth in this case?
0 个评论
采纳的回答
AndresVar
2022-2-14
编辑:AndresVar
2022-2-14
Something like this would add the gamma variable to your first table, BUT it's matching to nearest gamma
rophole12.gamma = interp1(gammahole12.depth1,gammahole12.gamma1,rophole12.depth,'nearest')
See: 1-D data interpolation (table lookup) - MATLAB interp1 (mathworks.com) for other matching options such as next or previeous
2 个评论
Cris LaPierre
2022-2-14
Using 'previous' seems to give the same results as vlookup.
holeid = [12;12;12;12;12;12;12;12;12;12;12;12;12;12;12;12];
depth = [0;0.0542;0.0801;0.2222;0.3959;0.4572;0.5110;0.5348;0.5712;0.6099;0.6437;0.6799;0.8011;0.8928;0.9590;1.0110];
rop = [118.7000;207.8000;139.6000;176.0000;177.8000;229.3000;242.4000;138.9000;85.7000;140.8000;164.5000;125.4000;189.8000;164.0000;118.4000;211.4000];
rophole12 = table(holeid,depth,rop);
holeid1 = [12;12;12;12;12;12;12;12;12;12;12;12;12];
depth1 = [0;0.13;0.22;0.36;0.48;0.56;0.67;0.78;0.84;0.96;1.03;1.14;1.24;];
gamma1 = [1;12;34;23;42;12;43;67;111;200;153;188;55];
gammahole12 = table(holeid1,depth1,gamma1);
% Use interp1 with method set to 'previous' to get same result as vlookup
% (for this example, at least)
rophole12.gamma = interp1(gammahole12.depth1,gammahole12.gamma1,rophole12.depth,'previous')
更多回答(1 个)
Cris LaPierre
2022-2-14
编辑:Cris LaPierre
2022-2-14
% Recreate your tables
holeid = [12;12;12;12;12;12;12;12;12;12;12;12;12;12;12;12];
depth = [0;0.0542;0.0801;0.2222;0.3959;0.4572;0.5110;0.5348;0.5712;0.6099;0.6437;0.6799;0.8011;0.8928;0.9590;1.0110];
rop = [118.7000;207.8000;139.6000;176.0000;177.8000;229.3000;242.4000;138.9000;85.7000;140.8000;164.5000;125.4000;189.8000;164.0000;118.4000;211.4000];
rophole12 = table(holeid,depth,rop);
holeid1 = [12;12;12;12;12;12;12;12;12;12;12;12;12];
depth1 = [0;0.13;0.22;0.36;0.48;0.56;0.67;0.78;0.84;0.96;1.03;1.14;1.24;];
gamma1 = [1;12;34;23;42;12;43;67;111;200;153;188;55];
gammahole12 = table(holeid1,depth1,gamma1);
% Use discretize to find the corresponding 'bin' gamma value
rophole12.gamma = discretize(rophole12.depth,[gammahole12.depth1;inf],gammahole12.gamma1)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!