Matlab: Question regarding dataset() -
i have around 50 elements (1 column char array) in workspace. there way put these elements single dataset without addressing each 1 explicitly. have variable x, lists element names. i've tried lots of things nothing seems work. dataset() not helpful in case. can me final obstacle before may see results.
if understand correctly, have 50 variables in workspace, names of stored in variable x
(which presume 50-element cell array). following example (with 3 variables) illustrates how set of variables 1 dataset:
>> var1 = ['a'; 'b'; 'c']; %# 3-by-1 character array >> var2 = ['d'; 'e'; 'f']; %# 3-by-1 character array >> var3 = ['g'; 'h'; 'i']; %# 3-by-1 character array >> x = {'var1'; 'var2'; 'var3'}; %# variable names in 3-by-1 cell array >> vardata = cellfun(@eval,x,'uniformoutput',false) %# collect variable data %# in cell array >> data = num2cell([vardata x],2); %# combine variable data %# variable names , collect each pair %# in additional cell array >> ds = dataset(data{:}) %# pass data dataset comma separated list ds = var1 var2 var3 d g b e h c f
Comments
Post a Comment