Borrar filtros
Borrar filtros

Array of Objects as a Property of Class

2 visualizaciones (últimos 30 días)
David OK
David OK el 20 de Dic. de 2020
Comentada: David OK el 23 de Dic. de 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

Respuesta aceptada

Matt J
Matt J el 20 de Dic. de 2020
Editada: Matt J el 20 de Dic. de 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

Más respuestas (0)

Categorías

Más información sobre Construct and Work with Object Arrays en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by