在Matlab中将行信息拆分为相等的间隔

时间:2017-07-19 11:06:40

标签: matlab

我有一张下表 - borehole_id深度从深度到深度颜色

DWASA030    0   3   3   Brown
DWASA030    3   6   3   Yellow
DWASA030    6   15  9   Grey
DWASA030    15  18  3   Black
DWASA030    18  21  3   Brown
DWASA030    21  30  9   Light Brown
DWASA030    30  34  4   Light Brown
DWASA030    34  37  3   Light Brown
DWASA030    37  46  9   Light Brown
DWASA030    46  82  36  Light Brown
DWASA030    82  104 22  Light Brown

我需要做的是将行分成2米的相等间隔(在负方向,即-2米间隔)。输出表将创建一个附加列(“除法”),该列用于计算负方向的间隔。如果有数据以奇数结尾,则会考虑先前的信息。例如,第一行有信息,其中土壤的棕色存在,直到距离顶部3米深。因此,它将从0开始,然后以-2米的间隔继续。然后在下一个级别达到4级时,它将继续使用棕色的现有值。 borehole_id深度从深度到深度颜色分割

DWASA030    0   3   3   Brown   0
DWASA030    0   3   3   Brown   -2
DWASA030    3   6   3   Yellow  -4
DWASA030    3   6   3   Yellow  -6
DWASA030    6   15  9   Grey    -8
DWASA030    6   15  9   Grey    -10
DWASA030    6   15  9   Grey    -12
DWASA030    6   15  9   Grey    -14
DWASA030    6   15  9   Grey    -16
DWASA030    15  18  3   Black   -18
DWASA030    18  21  3   Brown   -20
DWASA030    18  21  3   Brown   -22

反馈或如何在MATLAB中执行此操作将非常有用。

1 个答案:

答案 0 :(得分:0)

您将使用discretize()

据我所知,钻孔表按照发生深度的顺序列出了每个钻孔的位置。为了找到在特定深度处遇到的钻孔,可以将钻孔起始深度视为“分隔器”。或" bins"。

我还没有测试过这段代码,但你会按照以下方式做点什么:

% The depth at which each borehole starts.
startDepths = boreTable(:, 2)

% The range of depths to check for which borehole occurs.
checkDepths = 0:2:max(startDepths)

% Row indices that tell which borehole occurs
ind = discretize(checkDepths, startDepths)

% Generate the table with the new list of indices
boreTableNew = boreTable(ind, :)
相关问题