Matlab如何分组时间范围

use*_*870 0 time matlab loops

我有以下几次

1.1
1.15
1.19
1.32
1.69
2.12
2.36
2.86
3.25
3.67
3.77
3.91
...
Run Code Online (Sandbox Code Playgroud)

我希望MALTAB读取时间并将数字存储到数组中,其中数组1将在1-2秒内存储.阵列2将是2-3秒,依此类推.

提前感谢您提供的任何帮助/建议

Div*_*kar 5

您可以使用accumarray这些数组存储为单元格数组的单元格,如下所示 -

groups = accumarray(floor(timeseries),timeseries,[],@(x){x})
Run Code Online (Sandbox Code Playgroud)

样品运行 -

>> timeseries
timeseries =
          1.1
         1.15
         1.19
         1.32
         1.69
         2.12
         2.36
         2.86
         3.25
         3.67
         3.77
         3.91
>> groups = accumarray(floor(timeseries),timeseries,[],@(x){x});
>> celldisp(groups)  %// Display cells of output
groups{1} =
          1.1
         1.15
         1.19
         1.32
         1.69
groups{2} =
         2.12
         2.36
         2.86
groups{3} =
         3.25
         3.67
         3.77
         3.91
Run Code Online (Sandbox Code Playgroud)