Info
此问题已关闭。 请重新打开它进行编辑或回答。
Mapping signal segments to it's signal
1 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(0 个)
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!