"Nasser M. Abbasi" <email@example.com> wrote in message <firstname.lastname@example.org>... > On 11/30/2012 8:56 AM, Fiboehh wrote: > > > eval(['load ' fnames(k).name ' -ascii']); > > what is the deal with this eval thing? why not write normal > code and just call the function load() directly? > > Any reason you must do it this way? > > As for your question, > > >> I can't give the data a name to use in the calculations. > > may be you can simply use importdata? > > A=importdata('myfile.txt'); > or A=load(.....) > > and here is your variable. > > For text files better to use textscan or importdata I would think. > > --Nasser >
Thanx for the reply Nasser, The solutions you gave, work for only one 'direct' path file. I need to do this for all my files, so I 'm not planning to change 200 times the 'myfile.txt' name. The eval(['load ' fnames(k).name ' -ascii']); code I use to give the correct file (which is a string (converts number to string)), because the code below can't recognize the files correct.
for k = 1 : length(fnames) fname = fnames(k).name; log = impordata('fname.txt'); // fname is variable so this gives a problem disp(log) end