Thread View: comp.soft-sys.matlab
2 messages
2 total messages
Started by Jim Stockel
Tue, 26 Jan 1993 00:34
fscanf in v4.0
Author: Jim Stockel
Date: Tue, 26 Jan 1993 00:34
Date: Tue, 26 Jan 1993 00:34
18 lines
1218 bytes
1218 bytes
Hi, I'm fairly new to Matlab and have v4.0. A typical data file for me contains some strings for documentation/plot labeling, and some data. I've tried the [A,count] = fscanf(fid,'format',size) routine for reading strings, but it leaves something to be desired. With no size argument, it tries to read to the end of file. If a size argument is used then that is the number of whitespace seperated groups of characters are read (ie. words). Isn't there a way to read a newline terminated string? Am I missing something? Is there a better way to read strings? If anyone has any helpful hints I would be much obliged. If there is interest I will post a summary. Thanks, -jim -- Jim Stockel | stockel@taupo.oc.nps.navy.mil | (408) 656-3256 |
Re: fscanf in v4.0
Author: Ray Zimmerman
Date: Tue, 26 Jan 1993 14:44
Date: Tue, 26 Jan 1993 14:44
23 lines
1948 bytes
1948 bytes
In article <C1Fqxv.HKo@taurus.cs.nps.navy.mil> Jim Stockel,
stockel@taupo.oc.nps.navy.mil writes:
>I'm fairly new to Matlab and have v4.0. A typical data file for me
contains
>some strings for documentation/plot labeling, and some data. I've tried
>the [A,count] = fscanf(fid,'format',size) routine for reading strings,
>but it leaves something to be desired. With no size argument,
>it tries to read to the end of file. If a size argument is used
>then that is the number of whitespace seperated groups of characters are
>read (ie. words). Isn't there a way to read a newline terminated string?
>Am I missing something? Is there a better way to read strings?
Try "fgets" or "fgetl". If you need to extract pieces from the line
you can do that with "sscanf". This is what I've been doing and it
works ... but, as always, there may be a better way.
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Ray Zimmerman \ 397 Theory Center, Electrical Engineering
\ Cornell University, Ithaca NY 14853
Ray-Zimmerman@cornell.edu \ Phone: 607-254-8819 Fax: 607-255-9072
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
"The number you have dialed is imaginary.
Rotate phone 90 degrees and try again."
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads