Path: news.mathworks.com!not-for-mail
From: "Sadik " <sadik.hava@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Convert a list of strings 'x[1]', 'x[2]',... into workspace variable arrays.
Date: Tue, 22 Jan 2013 23:04:10 +0000 (UTC)
Organization: University of North Carolina
Lines: 15
Message-ID: <kdn5ta$5o3$1@newscl01ah.mathworks.com>
References: <kdn38u$pbp$1@newscl01ah.mathworks.com>
Reply-To: "Sadik " <sadik.hava@gmail.com>
NNTP-Posting-Host: www-05-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1358895850 5891 172.30.248.37 (22 Jan 2013 23:04:10 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 22 Jan 2013 23:04:10 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1666517
Xref: news.mathworks.com comp.soft-sys.matlab:787143

Hi Andrew,

I copied and pasted your list starting from 'on_state' directly from your post with no modification into a file named list.txt, did the following and it worked:

fid = fopen('list.txt')
c = textscan(fid,'%s %s')
names = c{1};
values = c{2};
names = strrep(names,'''','');
names = strrep(names,'[','(');
names = strrep(names,']',')')
linesToEval = strcat(names,repmat('=',length(names),1),values);
cellfun(@eval,ans);

Best.