Prev: Help me by checking this image accessing code using GUI.
Next: Regarding reading data from excel sheet
From: Thomas Ponath on 28 Jun 2010 08:47 Hallo, I loaded measurement data into MATLAB as a simple 'double' number table and naming them after the original file names, indicating measurement parameters. My script gives me a list of the variable names just as the command "s = who(variable_list) returns cell array s containing the names of the variables specified in variable_list [...]" (from Matlab help) Now I want to work with these variables (f.ex. integrate using trapz), without needing to type in their names but loading their names through my variable cell-list 's'. Is this possible without creating a redundant temporary variable via the command DATA = eval( s{i,1} ) %(for the i-th variable) ? Thank you in advance!
From: Steven Lord on 28 Jun 2010 09:15
"Thomas Ponath" <maberlioz(a)googlemail.com> wrote in message news:i0a5kb$aml$1(a)fred.mathworks.com... > Hallo, > I loaded measurement data into MATLAB as a simple 'double' number table > and naming them after the original file names, indicating measurement > parameters. So you created individual variables for each of your files? Don't do that -- load the data into fields of a struct array instead. > My script gives me a list of the variable names just as the command "s = > who(variable_list) returns cell array s containing the names of the > variables specified in variable_list [...]" (from Matlab help) > > Now I want to work with these variables (f.ex. integrate using trapz), > without needing to type in their names but loading their names through my > variable cell-list 's'. Is this possible without creating a redundant > temporary variable via the command DATA = eval( s{i,1} ) %(for > the i-th variable) ? If you created individual variables, I think you're stuck with EVAL. If you created fields in a struct array, use dynamic field names. S = struct('x', 1:10, 'y', [2 3 5 7]); myfield = 'x'; plot(S.(myfield)) Also see Q4.6 in the newsgroup FAQ. -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ To contact Technical Support use the Contact Us link on http://www.mathworks.com |