Prev: $$$$ YOU ARE JUST ONE CLICK TO MAKE DOLLAR ITS FREE
Next: How can get the integral of surface in 3-D
From: us on 27 Jul 2010 09:37 On Jul 27, 3:33 pm, "Wen Zhe " <wenzhe2...(a)hotmail.com> wrote: > Hi us, > > Thanks for the help link. Ermm, i gave it a show and here's the new code i'm trying: > > csvFiles = dir('*.csv'); > for k = 1:length(csvFiles) > filename = csvFiles(k).name; > data1 = importdata(filename); > end > > It still doesn't seem to be running though. Is the 'importdata' line correct? Note that my csv files contain both text and the numerical data which i'm more interested in. be more precise: which part is NOT working(?); WHAT do you expect from the output/loop(?)... us
From: Wen Zhe on 27 Jul 2010 09:47 Apologies for being unclear. I've re-ran the code and it worked fine. Here's the problem: i have three csv files and i want to import them onto Matlab as three seperate VARIABLES. With the current code, the output would be 'data1', but that would contain the data from the last csv file. So, is there any way to store my csv files in seperate variables without overwriting any of them? Any help appreciated. Thanks. us <us(a)neurol.unizh.ch> wrote in message <8319afb9-1b51-4c85-a02d-5e609922c02d(a)t35g2000vbb.googlegroups.com>... > On Jul 27, 3:33 pm, "Wen Zhe " <wenzhe2...(a)hotmail.com> wrote: > > Hi us, > > > > Thanks for the help link. Ermm, i gave it a show and here's the new code i'm trying: > > > > csvFiles = dir('*.csv'); > > for k = 1:length(csvFiles) > > filename = csvFiles(k).name; > > data1 = importdata(filename); > > end > > > > It still doesn't seem to be running though. Is the 'importdata' line correct? Note that my csv files contain both text and the numerical data which i'm more interested in. > > be more precise: which part is NOT working(?); WHAT do you expect from > the output/loop(?)... > > us
From: Andy on 27 Jul 2010 10:01 "Wen Zhe " <wenzhe2092(a)hotmail.com> wrote in message <i2mo1t$a1s$1(a)fred.mathworks.com>... > Apologies for being unclear. I've re-ran the code and it worked fine. Here's the problem: i have three csv files and i want to import them onto Matlab as three seperate VARIABLES. With the current code, the output would be 'data1', but that would contain the data from the last csv file. > > So, is there any way to store my csv files in seperate variables without overwriting any of them? Any help appreciated. Thanks. Perhaps you should consider storing the data in a cell array: csvFiles = dir('*.csv'); filename = cell(length(csvFiles),1); % preallocate data = cell(length(csvFiles),1); % preallocate for k = 1:length(csvFiles) filename{k} = csvFiles(k).name; data{k} = importdata(filename); end
From: us on 27 Jul 2010 10:04 On Jul 27, 4:01 pm, "Andy " <myfakeemailaddr...(a)gmail.com> wrote: > "Wen Zhe " <wenzhe2...(a)hotmail.com> wrote in message <i2mo1t$a1...(a)fred.mathworks.com>... > > > Apologies for being unclear. I've re-ran the code and it worked fine. Here's the problem: i have three csv files and i want to import them onto Matlab as three seperate VARIABLES. With the current code, the output would be 'data1', but that would contain the data from the last csv file. > > > So, is there any way to store my csv files in seperate variables without overwriting any of them? Any help appreciated. Thanks. > > Perhaps you should consider storing the data in a cell array: > > csvFiles = dir('*.csv'); > > filename = cell(length(csvFiles),1); % preallocate > data = cell(length(csvFiles),1); % preallocate > > for k = 1:length(csvFiles) > filename{k} = csvFiles(k).name; > data{k} = importdata(filename); > end well... either filename=csvFiles(k).name; or data{k}=importdata(filename{k}); :-) us
From: Walter Roberson on 27 Jul 2010 10:08 Wen Zhe wrote: a = cell(i,1); for j=1:i a{j} = importdata(files(j).name); end
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 Prev: $$$$ YOU ARE JUST ONE CLICK TO MAKE DOLLAR ITS FREE Next: How can get the integral of surface in 3-D |