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

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -