Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Multiple files into Matlab from Excel
Replies: 15   Last Post: May 9, 2014 2:06 AM

 Messages: [ Previous | Next ]
 Michelle Posts: 8 Registered: 5/3/14
Re: Multiple files into Matlab from Excel
Posted: May 6, 2014 5:17 AM

"Steven Lord" <Steven_Lord@mathworks.com> wrote in message <lk86dd\$5pb\$1@newscl01ah.mathworks.com>...
>
> "Michelle " <mictom@kth.se> wrote in message
> news:lk6rin\$n40\$1@newscl01ah.mathworks.com...

> > TideMan <mulgor@gmail.com> wrote in message

> >> On Monday, May 5, 2014 1:10:07 AM UTC+12, Michelle wrote:
> >> > "Bruno Luong" <b.luong@fogale.findmycountry> wrote in message
> >> > <lk5cqf\$8di\$1@newscl01ah.mathworks.com>...

>
> *snip*
>

> >> Show us the code you tried that didn't work.
> >
> > Thanks,
> > source_dir='/Users/MichelleTommosgard/Desktop/test';
> > source_files=dir(fullfile(source_dir,'*.xlsx'));
> >
> > n=length(source_files);
> >
> > i=n;

>
> Unnecessary. The variable i will be overwritten when you start your FOR
> loop.
>

> > a=cell(n);
>
> This creates an n-by-n cell array which will do what you want, but is
> overkill. Try cell(1, n) or cell(n, 1) instead.
>

> > for i=1:n
> > if i<=n

>
> Unnecessary. By the way you've written your FOR loop, i will ALWAYS be less
> than or equal to n.
>

> >
> > split=strsplit(source_files(i))

>
> Why are you doing this? For one thing, you never use the variable split
> later in the loop. For another, this will attempt to split _a field of the
> source_files struct array_ and so will probably error out.
>

>
> Again, why? While it is possible to mix cell arrays and struct arrays, that
> can get complicated really quickly. I recommend you stick with using cell
> arrays alone.
>

> > end
>
> Unnecessary, since you're going to remove the IF statement in this loop and
> this is the END associated with the IF.
>

> > end
>
> After this, the contents of the file whose name is source_files(k).name is
> in a{k}.
>
> --
> Steve Lord
> slord@mathworks.com
> http://www.mathworks.com

Hi,

thanks so much for the help, but I do not understand what you mean by "> Again, why? While it is possible to mix cell arrays and struct arrays, that
> can get complicated really quickly. I recommend you stick with using cell
> arrays alone."

Thanks

Date Subject Author
5/3/14 Michelle
5/3/14 dpb
5/3/14 Valeriy
5/3/14 dpb
5/4/14 Michelle
5/4/14 Bruno Luong
5/4/14 Michelle
5/4/14 Bruno Luong
5/4/14 Michelle
5/4/14 Michelle
5/4/14 Derek Goring
5/4/14 Michelle
5/5/14 Steven Lord
5/6/14 Michelle
5/6/14 Steven Lord
5/9/14 Michelle