Select part of a signal

3 Ansichten (letzte 30 Tage)
Paola
Paola am 30 Okt. 2018
Bearbeitet: KSSV am 30 Okt. 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

Antworten (0)

Kategorien

Mehr zu Denoising and Compression finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by