我是 matlab 的新手,我有一个包含二进制值的列向量 我想获取值从 0 变为 1 的索引,以及从 1 变为 0 时的索引。
这是我向 Stackoverflow 提出的第一个问题,因此我希望得到所需的帮助, 提前谢谢你。
最佳答案
将diff
与find
结合使用。
x = rand(1, 10) > 0.5
% all changes
find(diff(x)) + 1
% 0 to 1 and 0 to 1 separately
find(diff(x) == 1) + 1
find(diff(x) == -1) + 1
关于matlab - 检测二进制列向量的变化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9291253/