MATLAB: Want to create subclass of Dataset class in Stats Toolbox: How to pass arguments to dataset constructor in constructor for new class

constructordatasetinheritanceMATLABobject oriented programingStatistics and Machine Learning Toolboxsubclass

How to I pass arguments to the constructor spec = spec@dataset(input); I want to have the full range of input options available to the normal dataset class. That is multiple inputs of the form: DS = DATASET(…, {DATA,'name'}, …)
Should I be trying to create a string for the input argument and passing it using the EVAL(s) function?
classdef ramandataset < dataset
properties
ExperimentID
SampleID
ExciteWavelength
DateTaken
Apparatus
end
methods
function spec = ramandataset(data,names)
%RAMANDATASET Class Constuctor
% INPUT DATA: spec = ramandataset(data,names);
% where data is a double matrix of the form
% **********

% k ri k ri k ri
% **********
% and names is a 1 by n cell array of strings
if nargin == 0
super_args{1} = [0];
super_args{2} = '';
else
for i=1:size(data,2)/2
input = [];
super_args{1} = data(:,2*i-1:2*i);
super_args{2} = names{i};
input = {input super_args};
end %END FOR
end %END IF
spec = spec@dataset(input); %MY PROBLEM IS IN THIS LINE I THINK
end % END CONSTRUCTOR
end % END METHODS
methods
% % OVERLOADING
end
end % END CLASSDEF
Any advice would be most appreciated.

Best Answer

I'm not sure what exactly you are trying to do but if you want the full constructor capabilities of the dataset class you will need to allow your own class to take in a variable number of input arguments. So you'll need to use "varargin".
A second thing that might hold you up (it held me up) is how to pass a variable size cell array to the dataset constructor. You have to use "{:}" on the input.
Here's a very simple example:
classdef ramandataset < dataset
properties
end
methods
function spec = ramandataset(varargin)
spec = spec@dataset(varargin{:});
end % END CONSTRUCTOR
end % END METHODS
end
Heres an exmaple to test this:
data1 = randn(10,1);
data2 = randn(10,1);
ds = ramandataset({data1,'data1'},{data2,'data2'})
I'd start with this and add your custom modifications as you see fit. I'd also expect to overload the subsref and subsasgn functions.
It might take some time to get it all right but its been very worthwhile for my own work. I hope this helps a bit.