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: troubles with fscan
Replies: 5   Last Post: Jan 3, 2011 8:30 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Shanmugam Kannappan

Posts: 191
Registered: 9/9/08
Re: troubles with fscan
Posted: Jan 3, 2011 12:17 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Lucie Van Hove" wrote in message <ifrj8l$env$>...
> I have a problem with fscanf, and I know it will be something stupid, but I have read all the documentation and I cannot find the solution.
> I have a textfile with this format:
> aaaa
> bbbb
> cccc
> dddd
> I want to read this in to Matlab in a vector.
> But if I do
> fid = fopen('file.txt','r');
> if (fid < 0)
> error('could not open file "file.txt"');
> end;
> A = fscanf(fid,"%s",[1,inf])
> Then I get
> A = aaaabbbbccccdddd
> And that is obviously not what I want.
> Can anybody help me? Thanks


If you want it to be like a line by line
try using "textscan" with delimiter option as (\n).

you get it in a cell array with each line in one cell.


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.