Labfans是一个针对大学生、工程师和科研工作者的技术社区。 | 论坛首页 | 联系我们(Contact Us) |
![]() |
|
![]() |
#1 |
高级会员
注册日期: 2019-11-21
帖子: 3,006
声望力: 66 ![]() |
![]()
假设您的序列很长。查找序列全为零的时间间隔(或更准确地说,序列下降到接近零的值abs(X) =的间隔达到某个指定值(例如3 ),并在所有这些间隔组合中返回值的索引:
indices = [3 4 5 6 14 15 16]; 最后一部分与上一个问题有关: MATLAB:从开始/结束索引列表创建向量化数组这是我到目前为止的内容: sig = [1 1 0 0 0 0 1 1 1 1 1 0 1 0 0 0 1 1 1 1 1 1 1 1 0 0 1 1 1 0]; len = length(sig); thresh = 3; %# align the signal with itself successively shifted by one %# v will thus contain 1 in the starting locations of the zero interval v = true(1,len-thresh+1); for i=1:thresh v = v & ( sig(i:len-thresh+i) == 0 ); end %# extend the 1's till the end of the intervals for i=1:thresh-1 v(find(v)+1) = true; end %# get the final indices v = find(v); 我正在寻求矢量化/优化代码,但是我对其他解决方案持开放态度。我必须强调空间和时间效率非常重要,因为我正在处理大量的长生物信号。 回答: 从给定的vector sig开始,我将按照以下这些步骤以向量化的方式解决您的问题:
更多&回答... |
![]() |
![]() |