MATLAB: How can assign aliases to column names in a dataset array in the Statistics Toolbox 7.1 (R2009a)

accessaliascolumndatasetdynamicmodifyStatistics and Machine Learning Toolboxstructure

I want to know if there is a way to alias the column names in a dataset array.
For example, if I have a dataset with column names:
DataSheet.ScoreF
DataSheet.ScoreK
When addressing these columns it would be nice to compactly address these columns:
for k = 1:NumCols
DataSheet.k = -1
end
rather than
DataSheet.ScoreF = -1;
DataSheet.ScoreK = -1;
This would lead to large savings as I have 100 columns to access and modify.

Best Answer

The example below demonstrates how to achieve the desired functionality. In the example, after the dataset is created, its column names are stored in a variable. The column names can then be used to dynamically access/modify the data in the dataset as follows:
load fisheriris
NumObs = size(meas,1);
NameObs = strcat({'Obs'},num2str((1:NumObs)','%d'));
iris = dataset({meas,'SL','SW','PL','PW'},...
'ObsNames',NameObs);
h1 = iris.Properties.VarNames; %get column names and assign them to a variable
for i = 1:size(h1,2)
iris.(h1{i}) = -1*ones(150,1);
end