Array of Objects as a Property of Class
2 views (last 30 days)
Show older comments
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
0 Comments
Accepted Answer
Matt J
on 20 Dec 2020
Edited: Matt J
on 20 Dec 2020
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
More Answers (0)
See Also
Categories
Find more on Matrices and Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!