Select part of a signal

3 views (last 30 days)
Paola
Paola on 30 Oct 2018
Edited: KSSV on 30 Oct 2018
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

Answers (0)

Categories

Find more on Denoising and Compression in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!