Effacer les filtres
Effacer les filtres

Array of Objects as a Property of Class

2 vues (au cours des 30 derniers jours)
David OK
David OK le 20 Déc 2020
Commenté : David OK le 23 Déc 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

Réponse acceptée

Matt J
Matt J le 20 Déc 2020
Modifié(e) : Matt J le 20 Déc 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
  1 commentaire
David OK
David OK le 23 Déc 2020
Thank you very much!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Construct and Work with Object Arrays dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by