matlab - Using "who" variable list to open cell array -


i trying cycle through list of variables have 30+ , calculate maximum , minimum value each column in each variable. save in new array , export excel.

my thoughts use function create array name of variables present. cycling through each 1 using loop after working out size of array created. works fine, when try , use string reference array not work.

i add in code have written able come easy solution :).

variable_list = cell2 = input('what cell size want at? '); startcell = input('what start cell size? '); [num_variables, temp] = size(variable_list); va = 1:num_variables      variable = variable_list{va}          [max_value, max_index] = max(variable{cell2/startcell})      [min_value, min_index] = min(variable{cell2/startcell})      format_values{va} = vertcat(max_values, max_index, min_value, min_index); end 

the variables looking @ arrays why use cell2/startcell reference them.

you need use eval() function able value of variable corresponding string. example:

a = 1; b = 2; variable_list = who; c = eval(variable_list{2}); 

results in c being 2. in code, following line needs change from:

variable = variable_list{va} 

to:

variable = eval(variable_list{va}); 

resulting in variable having value of variable indicated string variable_list{va}. if variable of cell type, should fine, otherwise may have revise next 2 lines of code because seems trying access content of cell.


Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -