The Math Forum

Search All of the Math Forum:

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

Math Forum » Discussions » Software » comp.soft-sys.matlab

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

Topic: reading text file line by line
Replies: 10   Last Post: Aug 4, 2012 8:50 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Leyo Joseph

Posts: 67
Registered: 3/19/09
Re: reading text file line by line
Posted: Aug 3, 2012 6:27 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

TideMan <> wrote in message <>...
> On Saturday, August 4, 2012 7:03:27 AM UTC+12, Leyo Joseph wrote:
> > Hello,
> >
> >
> >
> > I have a big text file called data.txt. Would like to read this to Matlab.
> >
> > I am trying to do this with the following code==>
> >
> >
> >
> > KK=fopen('F:\commands\data.txt');
> >
> > A=fscanf(KK,'%s');
> >
> >
> >
> > This reads the whole content of data.txt to A without any line breaks or spaces. How to make it read line by line and keeping the spaces as in data.txt?
> >
> >
> >
> > Thanks
> >
> > Leyo

> A=fscanf(fid,'%c');

This method works...not exactly as I want.

my data.txt file is something like this==>

Reading the Power to input of Pre-Scaler

Block read from MERA3

Register Data

0x3028 0x0455920f

0x3029 0x0455964f

0x302a 0x0455950f

0x302b 0x0455910f

Is it possible to read in such a way that A(1,1) is the first whole line, A(1,2) is the second whole line so on...
Also is there a way to skip the read if a particular line is empty?

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.