Array of Objects as a Property of Class
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
David OK
am 20 Dez. 2020
Kommentiert: David OK
am 23 Dez. 2020
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 Kommentare
Akzeptierte Antwort
Matt J
am 20 Dez. 2020
Bearbeitet: Matt J
am 20 Dez. 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
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Construct and Work with Object Arrays finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!