How can I use a variable to create MATLAB elements? -


possible duplicates: how concatenate number variable name in matlab? matlab: how can use variables value in variables name?

i have following code:

x = textread('/home/data/data.txt','%s') i=1:50     s=load(['/home/data/',x{i},'_file.mat'])     info_',x{i},' = strcat(s.info1, s.info2) end 

of course, last line (info_',x{i},' = strcat(s.info1, s.info2)) doesn't work. doesn't seem possible use variable create matlab elements. right or doing wrong here? there elegant workaround?

do want like

eval( sprintf( 'info_%s = strcat( s.info1, s.info2 );', x{i} ) ); 

?

if so, discourage doing so, see: http://matlab.wikia.com/wiki/faq#how_can_i_create_variables_a1.2c_a2.2c....2ca10_in_a_loop.3f


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -