Select part of a signal
3 次查看(过去 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 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Denoising and Compression 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!