Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
text file data

Subject: text file data

From: Charles

Date: 25 Mar, 2009 21:58:01

Message: 1 of 5

I have a text file simular to the one seen below:

day month year
3 2 1985
2 5 1728
5 7 1896

arm leg foot
4 3 9
2 4 9
3 6 7

When I attempt to load the file in matlab using importdata() I am only seeing the data under day, month, year. Is there a way to make MATLAB detect the second portion of data within the same file?

Subject: text file data

From: Miroslav Balda

Date: 25 Mar, 2009 22:26:01

Message: 2 of 5

"Charles" <charles.vaughan@colorado.edu> wrote in message <gqe9d9$lv7$1@fred.mathworks.com>...
> I have a text file simular to the one seen below:
>
> day month year
> 3 2 1985
> 2 5 1728
> 5 7 1896
>
> arm leg foot
> 4 3 9
> 2 4 9
> 3 6 7
>
> When I attempt to load the file in matlab using importdata() I am only seeing the data under day, month, year. Is there a way to make MATLAB detect the second portion of data within the same file?

Hi,
Use txt2mat from FEX.
Mira

Subject: text file data

From: Steve

Date: 2 Jun, 2009 21:03:01

Message: 3 of 5

> Hi,
> Use txt2mat from FEX.
> Mira

Is this the only way to do it? I also have the same type of format. I am trying to read in all the lines as a character array even though there are rows with numbers but importdata seems to get stuck on rows with no data.

Subject: text file data

From: Andres

Date: 4 Jun, 2009 15:33:01

Message: 4 of 5

"Steve" <defender96@gmail.com> wrote in message <h04425$63c$1@fred.mathworks.com>...
> > Hi,
> > Use txt2mat from FEX.
> > Mira
>
> Is this the only way to do it? I also have the same type of format. I am trying to read in all the lines as a character array even though there are rows with numbers but importdata seems to get stuck on rows with no data.


txt2mat will read in the numeric data quite easily, but if the labelling lines inbetween ('arm leg foot') contain arbitrary text, and you need to import them as well, you'd better write some custom import function, preferrably based on textscan

Subject: text file data

From: Steve

Date: 4 Jun, 2009 16:01:02

Message: 5 of 5

"Andres" <rantore@werb.deNoRs> wrote in message <h08pfd$cn3$1@fred.mathworks.com>...
> "Steve" <defender96@gmail.com> wrote in message <h04425$63c$1@fred.mathworks.com>...
> > > Hi,
> > > Use txt2mat from FEX.
> > > Mira
> >
> > Is this the only way to do it? I also have the same type of format. I am trying to read in all the lines as a character array even though there are rows with numbers but importdata seems to get stuck on rows with no data.
>
>
> txt2mat will read in the numeric data quite easily, but if the labelling lines inbetween ('arm leg foot') contain arbitrary text, and you need to import them as well, you'd better write some custom import function, preferrably based on textscan

Thanks for the info. Yeah txt2mat wasn't doing exactly what I wanted. With a little code and manipulation I was able to get what I wanted with just importdata.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us