Select part of a signal

조회 수: 3 (최근 30일)
Paola
Paola 2018년 10월 30일
편집: KSSV 2018년 10월 30일
Hello,
I have a 6xN matrix and a 1 dimension vector (made of 0 and 1) (ex: 000000000000000111110000000000.) I need to select part of the matrix, in correspondence of the "1" in the vector. (they temporally start together), and divide the selected signal in blocks.
What I have is:
DStimData = diff(round(StimData));
blockonoff = find(DStimData~=0);
%Where StimData is my "1-0" vector.
blockonoff = blockonoff(find(flagblockonoff));
trialonset = intersect(find(DStimData>0),blockonoff);
trialoffset = intersect(find(DStimData<-0),blockonoff);
t = 1;
for k = 1:length(trialonset)
onsettime = trialonset(k);
OffOnDiff = trialoffset - onsettime;
GoodOffset = trialoffset(find(OffOnDiff>0));
if ~isempty(GoodOffset),
offsettime = min(GoodOffset);
onsettime = onsettime + 1;
segmentONtime = max(1,onsettime-pretimeN);
segmentOFFtime = min(offsettime+posttimeN,size(ForceData,2));
segmentlength = segmentOFFtime - segmentONtime + 1;
On these parts of signal I apply my analysis.
Now I need an improvement: after plotting my selected signal, in some cases, I need to do the analysis again, excluding some part of the signal, even when the "1" is present. How can I be more flexible in the selection of my signal? Is there a better way also to improve the old code?
Thank You in advance

답변 (0개)

카테고리

Help CenterFile Exchange에서 Denoising and Compression에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by