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
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
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
2020년 6월 8일
Do look into the documentations for the reshape function to see how it works.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Measurements and Feature Extraction에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!