How to alternatively cut a signal into segments of different sizes

4 次查看(过去 30 天)
I have an EMG signal of duration 680 seconds, i want to make segments of this signal starting from the 1st 6 seconds and then the next 8 seconds and repeat this procedure till i have reached 680 seconds;i want to make alternative segments of 6s and 8s and then i want to concatenate the 6s data into 1 variable and 8 seconds into another variable. The final step is to to grow size of the 6s variable to 8s so that both the variables becomes of the same time. 6 seconds represents rest while the next 8s represents contraction. This set is repeated 10 times like rest for 6s and then contraction for the next 8s.
  4 个评论

请先登录,再进行评论。

采纳的回答

Mohammad Sami
Mohammad Sami 2020-6-4
编辑:Mohammad Sami 2020-6-4
You can use reshape to extract the signals
% Incorrect : prb2 = reshape(prb,14*2048,2,[]);
% Correction
prb2 = reshape(prb,14*2048,[],2);
prbsix = prb2(1:(6*2048),:,:);
prbeight = prb2((6*2048+1):end,:,:);
prbsix = [ prbsix ; zeros(2*2048,size(prbsix,2),size(prbsix,3))]; % pad with zeros
If you wish to reshape it back to 2D, you can do as follows
prbeight = reshape(prbeight,[],2);
prbsix = reshape(prbsix,[],2);
  14 个评论
Mohammad Sami
Mohammad Sami 2020-6-8
Yes that should be correct for a 3 channel or n channel data as well.
The code does assume that your signal lenght will be divisible by 14s. It that is not the case you will get an error message.
Your summary is sort of correct except the reshape allows us to do it all in one go, rather then have to repeat for each individual block.
Mohammad Sami
Mohammad Sami 2020-6-8
Do look into the documentations for the reshape function to see how it works.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Measurements and Feature Extraction 的更多信息

产品


版本

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by