function  tsmat_columns(X,varargin)
%@tsmat\tsmat_columns
% defines in workspace as many variables as there are columns
% and with names in the field specified (default is label)

[T,N]=size(X);
if nargin==1
names=genvarname(X.meta_cols.label);
else
    metaname=varargin{1};
    metas=X.meta_cols;
    if isfield(metas,metaname)
        names=genvarname(metas.(metaname));
    else
        error(['The field ', metaname,' does not belong to any meta_cols']);
    end
    
end
%varargout{1}=names;
for q=1:N
    assignin('base',names{q},X(:,q));
    disp(q)
end