[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Problem using fscanf
From: |
Bård Skaflestad |
Subject: |
Re: Problem using fscanf |
Date: |
Fri, 15 Apr 2011 09:53:04 +0200 |
On Fri, 2011-04-15 at 07:34 +0200, Utherr13 wrote:
> It only shows me the first line. I want all lines from the file.
What is "it"? Your original code?
Did you try my suggestion? Here's a more complete demonstration. Maybe
you can pinpoint the spot where this approach does not produce the
results you expected:
# Create test data file:
x = floor(100 * rand([100, 2])); # create some data
f = fopen("data.txt", "w"); # error checking omitted
fprintf(f, "%d %d\n", x .'); # output data to file
fclose(f);
# Read data back in:
f = fopen("data.txt", "r"); # error checking omitted
t = fscanf(f, "%d", [2, 100]) .'; # [2,100]+transpose essential
fclose(f);
# Compare to original
all(all(t == x))
By the way, this problem might be easier to attack using the "load"
function.
Sincerely,
--
Bård Skaflestad <address@hidden>
SINTEF ICT, Applied Mathematics
- Problem using fscanf, Utherr13, 2011/04/14
- Re: Problem using fscanf, Doug Stewart, 2011/04/14
- Re: Problem using fscanf, Bård Skaflestad, 2011/04/14
- Re: Problem using fscanf, Utherr13, 2011/04/15
- Re: Problem using fscanf,
Bård Skaflestad <=
- octave from java, frank buloup, 2011/04/15
- Re: octave from java, George Kousiouris, 2011/04/15
- Re: octave from java, Kim Hansen, 2011/04/15
- Re: octave from java, Utherr13, 2011/04/15
- Re: octave from java, frank buloup, 2011/04/15
- Re: octave from java, Kim Hansen, 2011/04/17
- Re: Problem using fscanf, Utherr13, 2011/04/15
- Re: Problem using fscanf, Bård Skaflestad, 2011/04/15
- Re: Problem using fscanf, Bård Skaflestad, 2011/04/15
- Re: Problem using fscanf, Jordi Gutiérrez Hermoso, 2011/04/15