dataset allows us to do:
x = rand(10, 1);
y = rand(10, 1);
d = dataset(x, y);
d will have 2 variables with name 'x' and 'y' and content x and y - variable names are obtained from the workspace. The dataset() call above is equivalent to:
d = dataset({'x', x}, {'y', y});
when the names are specified.
Now if I have a subclass of dataset:
classdef mydataset < dataset
properties
end
methods
function spec = mydataset(varargin)
spec = spec@dataset(varargin{:});
% Add some more things to this subclass because that's the reason I need a subclass
end
end
end
The problem is, if I call:
d = mydataset(x);
d will have the variable x but the name is just 'var1'. The workspace name 'x' is not recognized. Unless I call:
d = mydataset({'x', x});
I will not get the same effect.
Any solution?
Note that I do not want to lose other argument parsing abilities of dataset(). It can process really complicated arguments, and I do want to preserve that.
http://www.mathworks.com/help/toolbox/stats/dataset.html
A = dataset(varspec,'ParamName',Value)
A = dataset('File',filename,'ParamName',Value)
A = dataset('XLSFile',filename,'ParamName',Value)
A = dataset('XPTFile',xptfilename,'ParamName',Value)
The example in this question with mydataset(x) is the a simple and commonly encountered situation that mydataset() can't pass things to dataset() and obtain the same results. Thus it's an important situation. But to do just that and lose other capabilities of dataset() is not worth it.