From: Wen Zhe on
Hi all,

Just a simple question concering important multiple data onto Matlab.

I've rewritten the following code so far and all seems to be working well:

files = dir('*.csv');

for i=1:length(files)

eval(['importdata ' files(i).name ' ']);

end

Here's the thing. I want to save each data file as a seperate unique variable. How do i do that? Currently, it's overwriting a variable called 'ans'.

Hope to get some assistance soon. Thanks!

Wen
From: us on
"Wen Zhe " <wenzhe2092(a)hotmail.com> wrote in message <i2meis$lbh$1(a)fred.mathworks.com>...
> Hi all,
>
> Just a simple question concering important multiple data onto Matlab.
>
> I've rewritten the following code so far and all seems to be working well:
>
> files = dir('*.csv');
>
> for i=1:length(files)
>
> eval(['importdata ' files(i).name ' ']);
>
> end
>
> Here's the thing. I want to save each data file as a seperate unique variable. How do i do that? Currently, it's overwriting a variable called 'ans'.
>
> Hope to get some assistance soon. Thanks!
>
> Wen

a hint:

http://matlabwiki.mathworks.com/MATLAB_FAQ#How_can_I_process_a_sequence_of_files.3F

us
From: Srikanth on
Please try this:

for j=1:i
a(j,1) = importdata(files(j).name);
end

"Wen Zhe " <wenzhe2092(a)hotmail.com> wrote in message <i2meis$lbh$1(a)fred.mathworks.com>...
> Hi all,
>
> Just a simple question concering important multiple data onto Matlab.
>
> I've rewritten the following code so far and all seems to be working well:
>
> files = dir('*.csv');
>
> for i=1:length(files)
>
> eval(['importdata ' files(i).name ' ']);
>
> end
>
> Here's the thing. I want to save each data file as a seperate unique variable. How do i do that? Currently, it's overwriting a variable called 'ans'.
>
> Hope to get some assistance soon. Thanks!
>
> Wen
From: Wen Zhe on
Hi,

I gave this a go but the following error message appeared:

??? Subscripted assignment between dissimilar structures.

Why is this the case? Note my csv files contain headers and the numerical data which i am more interested in.

Many thanks.

"Srikanth " <neevenenu(a)yahoo.com> wrote in message <i2mmat$fmq$1(a)fred.mathworks.com>...
> Please try this:
>
> for j=1:i
> a(j,1) = importdata(files(j).name);
> end
>
> "Wen Zhe " <wenzhe2092(a)hotmail.com> wrote in message <i2meis$lbh$1(a)fred.mathworks.com>...
> > Hi all,
> >
> > Just a simple question concering important multiple data onto Matlab.
> >
> > I've rewritten the following code so far and all seems to be working well:
> >
> > files = dir('*.csv');
> >
> > for i=1:length(files)
> >
> > eval(['importdata ' files(i).name ' ']);
> >
> > end
> >
> > Here's the thing. I want to save each data file as a seperate unique variable. How do i do that? Currently, it's overwriting a variable called 'ans'.
> >
> > Hope to get some assistance soon. Thanks!
> >
> > Wen
From: Wen Zhe on
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.

Many thanks.

"us " <us(a)neurol.unizh.ch> wrote in message <i2mfd5$edl$1(a)fred.mathworks.com>...
> "Wen Zhe " <wenzhe2092(a)hotmail.com> wrote in message <i2meis$lbh$1(a)fred.mathworks.com>...
> > Hi all,
> >
> > Just a simple question concering important multiple data onto Matlab.
> >
> > I've rewritten the following code so far and all seems to be working well:
> >
> > files = dir('*.csv');
> >
> > for i=1:length(files)
> >
> > eval(['importdata ' files(i).name ' ']);
> >
> > end
> >
> > Here's the thing. I want to save each data file as a seperate unique variable. How do i do that? Currently, it's overwriting a variable called 'ans'.
> >
> > Hope to get some assistance soon. Thanks!
> >
> > Wen
>
> a hint:
>
> http://matlabwiki.mathworks.com/MATLAB_FAQ#How_can_I_process_a_sequence_of_files.3F
>
> us