help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reading a text file


From: Jaroslav Hajek
Subject: Re: Reading a text file
Date: Thu, 29 May 2008 15:09:17 +0200

On Thu, May 29, 2008 at 2:35 PM, browny <address@hidden> wrote:
>
> Hi, I am trying to read some data from a text file with each column as a
> separate array. Im not really sure how to do it as it contains text, numbers
> plus other characters.
>
> The data I am trying to read can be found here
> http://astronomy.swin.edu.au/ska/Research/1718-fluxes.txt
>
> With the data it is currently in the form "3.915+/-0.017". I would like to
> read this into two separate arrays, one containing the "3.915" the other
> containing "0.017"...as numbers, not strings.
>
> Some of the fields contain "-------------" instead of a value like the one
> above and I would like this to be read as an empty value so I can plot the
> data without it being assigned to the wrong x value.
>
> Thanks for any help or advice you can give.
> --
> View this message in context: 
> http://www.nabble.com/Reading-a-text-file-tp17534743p17534743.html
> Sent from the Octave - General mailing list archive at Nabble.com.
>
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://www.cae.wisc.edu/mailman/listinfo/help-octave
>

if there is not excessively many data, then you can read line by line
using fgets(),
replace "+/-" by "   " and "-------------" by "0.000 0.000", then use
sscanf to read the row into a matrix.


-- 
RNDr. Jaroslav Hajek
computing expert
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz


reply via email to

[Prev in Thread] Current Thread [Next in Thread]