Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


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

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 7:15 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

dpb <none@non.net> wrote in message <jvhl22$e9$1@speranza.aioe.org>...
> On 8/3/2012 5:27 PM, Leyo Joseph wrote:
> ...
>

> > 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...

> ...
>
> That's what the other solution does--returns a cell string, one per record.
>
> Alternatively, try
>
> A=cellstr(A);
>
> Probably easiest to get rid of the blank lines is to do so after reading
> the full file into memory.
>
> Alternatively,
>
> fid=fopen('yourfile','rt');
> a=fgetl(fid);
> while ~feof(fid)
> l=fgetl(fid);
> if ~isempty(l)
> a=strvcat(a,l);
> end
> end
> c=cellstr(a);
>
> --
>
>
>
> --

Thanks for thr help... I am getting closer, but need one more analysis.
When I try the above, for example , I get
c(5,1)

ans =

' 0x3029 0x04548ecf'

how to copy 0x04548ecf from c(5,1) to a variable?. I wan to do this for other (c:,1)
Thnaks



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

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.