find 'name' not the value of variable that holds maximum value matlab -


assume have 30 variables, looking way find value hold biggest value. need 'name' of it, not value of it. example:

i1=10 i2=12 i3=14 i4=90 i5=5 i6=90 

how can code function return 'i4' , 'i5'. not return 90.

one way first find maximum comparing each variable can find out name of variable. but, not efficient if have lot of variables. has idea? in advance.

it's better use cell arrays sort of thing, anyway this:

names = who('-regexp', 'i[0-9]+'); values = cellfun(@eval, names); maxvalue = max(values); maxnames = names(values == maxvalue) 

Popular posts from this blog

javascript - Js, document.getElementById("ID").innerHTML, error -

objective c - Is there a way in OCMockito to make stubs fail when an unknown method is called? -

jquery - jqGrid update specific column data with out refreshing the entire column? -