Matlab如何对时间范围进行分组

编程入门 行业动态 更新时间:2024-10-25 08:19:03
本文介绍了Matlab如何对时间范围进行分组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有以下几次

1.1 1.15 1.19 1.32 1.69 2.12 2.36 2.86 3.25 3.67 3.77 3.91 ...

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

And I would like MALTAB to read the times and store the numbers into arrays where array 1 would be for times in 1-2 seconds. Array 2 would be 2-3 seconds and so on.

在此先感谢您提供的帮助/建议

Thanks in advance for any help/advice given

推荐答案

您可以使用 accumarray 将这些数组存储为单元格数组的单元格,就像这样-

You could use accumarray to have those arrays stored as cells of a cell array, like so -

groups = accumarray(floor(timeseries),timeseries,[],@(x){x})

样品运行-

>> 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

更多推荐

Matlab如何对时间范围进行分组

本文发布于:2023-10-24 09:43:59,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1523608.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:时间   Matlab

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!