From: "Daniel Robbins" <>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Loading multiple files into a dataset
Date: Wed, 13 Jun 2012 16:37:07 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 18
Message-ID: <jrafjj$i8$>
References: <jr7evo$a9k$> <jr7k9u$5fb$> <jr7lfr$au4$> <jr7sae$cdg$>
Reply-To: "Daniel Robbins" <>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1339605427 584 (13 Jun 2012 16:37:07 GMT)
NNTP-Posting-Date: Wed, 13 Jun 2012 16:37:07 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2776992
Xref: comp.soft-sys.matlab:771006

Hi Steve,

I have tried both the methods on the link you provided, but I find that all of the data is not stored, only the first number in the text file is stored. If I use the importdata function then I can load the entire text file e.g.


for k = 1: length(textfiles)
            textfilename = [num2str (k), '.txt];
            a = importdata (textfilename);

However this over writes the data with each loop. I have googled around to look if there is anyway to create sequential variables e.g. a1,a2,a3...etc. However there are lots of pages indicating this is not the way to go.

The ultimate goal is to get all the text files loaded and combined in to one dataset, however I would like to be able to get MATLAB to read direct from the text files rather then load them each into excel organise them and then load using the dataset function. Obviously this would be very time consuming... 

Any help will be much appreciated.