Info

This question is closed. Reopen it to edit or answer.

Mapping signal segments to it's signal

1 view (last 30 days)
JA
JA on 25 Jul 2016
Closed: MATLAB Answer Bot on 20 Aug 2021
I have an algorithm which chops the signal based on some parameters and stores it in a structure.
Code:
classdef Container < handle
properties
segments = struct('signal', {}, 'time', {});
end
methods
function this = addsignal(this, varargin)
interval = diff(varargin{2});
[~, locations] = findpeaks(interval,'THRESHOLD',0.7)
edges = [0; locations; numel(varargin{1})+1]; %note that 0 and one past the end is on purpose
newsegments = struct('signal', cell(numel(edges)-1, 1), 'time', cell(numel(edges)-1, 1), 'error', []);
%this loop works for no peaks, 1 peak and more than one peak (because of the 0 and numel+1)
for edgeidx = 1 : numel(edges) - 1
newsegments(edgeidx).signal = varargin{1}((edges(edgeidx)+1 : edges(edgeidx+1)-1));
newsegments(edgeidx).time = varargin{2}(edges(edgeidx)+1 : edges(edgeidx+1)-1);
end
this.segments = [this.segments; newsegments]; %and append structure
end
this is how i call this fucntion:
f = ltifilter.container(); % ltifilter is a package
f.addsignal(signal1,time1);
f.addsignal(signal2,time2);
f.addsignal(signal3,time3);
When i call with all signals, segments structure will have all the chopped segments of all the signal combined, there is no way of saying which segment belongs to which signal, i want to map the segments to it's parent signal like this:
Any suggestion will be helpful

Answers (0)

Community Treasure Hunt

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

Start Hunting!