Array of Objects as a Property of Class

3 次查看(过去 30 天)
I have created a custom class for handling ECG files. Originally I programmed it to handle (eg. filter, detrend etc.) the entire file at once.
I would now like to handle it segment by segment instead, and I thought I could do this by creating an array of ECG objetcs (one for each segment) as a property of the class as follows:
However when I try to run the segment method, I am told I cannot convert double to ECG.
How can I define an array of ECGs as the property instead of an array of doubles?
classdef ECG < handle
properties (SetAccess = private)
Segment {ismatrix}
end
methods
function segmentECG(obj,varargin)
for i = 1:SegNum
segSignal = obj.signal(i*SegLen : 2*i*SegLen-1);
obj.Segment(i) = ECG(segSignal,obj.Fs);
end
end

采纳的回答

Matt J
Matt J 2020-12-20
编辑:Matt J 2020-12-20
classdef ECG < handle
properties (SetAccess = private)
Segment {ismatrix}
end
methods
function segmentECG(obj,varargin)
c=cell(1,SegNum);
for i = 1:SegNum
segSignal = obj.signal(i*SegLen : 2*i*SegLen-1);
c{i} = ECG(segSignal,obj.Fs);
end
obj.Segment=[c{:}];
end

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Construct and Work with Object Arrays 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by