Thread Subject: load ASCII file with rows of different length

Subject: load ASCII file with rows of different length

From: trave Traverso

Date: 31 Aug, 2009 18:15:18

Message: 1 of 5

I need to load a file with this structure:
 
       40 40 50
   1
   1
   2
   2
   4
   1
   1
   1
   1

I am not sure what's the best way to do it. Note that I wouldn't want to modify the original file, i.e. I can't delete the first row and use the load function.

Any suggestion would be great.

LT

Subject: load ASCII file with rows of different length

From: Abel Brown

Date: 31 Aug, 2009 18:25:18

Message: 2 of 5

did you try the "importdata" function?

Subject: load ASCII file with rows of different length

From: us

Date: 31 Aug, 2009 18:26:19

Message: 3 of 5

"trave Traverso" <trave80@gmail.com> wrote in message <h7h3vm$e4g$1@fred.mathworks.com>...
> I need to load a file with this structure:
>
> 40 40 50
> 1
> 1
> 2
> 2
> 4
> 1
> 1
> 1
> 1
>
> I am not sure what's the best way to do it. Note that I wouldn't want to modify the original file, i.e. I can't delete the first row and use the load function.
>
> Any suggestion would be great.
>
> LT

one of the solutions (using pseudo-code)
- based on TEXTREAD...

- read the header using the N option
     ...=textread('filename','format',N);

- read the data using the HEADERLINES option
     ...=textread('filename','format','headerlines',1);

us

Subject: load ASCII file with rows of different length

From: trave Traverso

Date: 1 Sep, 2009 08:17:03

Message: 4 of 5

thanks a lot for your help,

best

LT

"us " <us@neurol.unizh.ch> wrote in message <h7h4kb$pmf$1@fred.mathworks.com>...
> "trave Traverso" <trave80@gmail.com> wrote in message <h7h3vm$e4g$1@fred.mathworks.com>...
> > I need to load a file with this structure:
> >
> > 40 40 50
> > 1
> > 1
> > 2
> > 2
> > 4
> > 1
> > 1
> > 1
> > 1
> >
> > I am not sure what's the best way to do it. Note that I wouldn't want to modify the original file, i.e. I can't delete the first row and use the load function.
> >
> > Any suggestion would be great.
> >
> > LT
>
> one of the solutions (using pseudo-code)
> - based on TEXTREAD...
>
> - read the header using the N option
> ...=textread('filename','format',N);
>
> - read the data using the HEADERLINES option
> ...=textread('filename','format','headerlines',1);
>
> us

Subject: load ASCII file with rows of different length

From: trave Traverso

Date: 1 Sep, 2009 08:18:03

Message: 5 of 5

"Abel Brown" <brown.2179@osu.edu> wrote in message <h7h4ie$lrh$1@fred.mathworks.com>...
> did you try the "importdata" function?

thanks for your help.

best

LT

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

Tag Activity for This Thread
Tag Applied By Date/Time
reference us 31 Aug, 2009 14:29:25
textread us 31 Aug, 2009 14:29:25
rssFeed for this Thread

Contact us at files@mathworks.com