help-octave
[Top][All Lists]
Advanced

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

Re: Including NaNs in a data file?


From: Alasdair McAndrew
Subject: Re: Including NaNs in a data file?
Date: Thu, 6 Nov 2014 10:44:59 +1100

Thank you - they work well.  In fact, if the ascii file contains

 1 2 NA 3 4

then textread('file.txt') does the job, and further computation can be done using nansum, nanmean etc from the statistics package.

Thanks again!

On Thu, Nov 6, 2014 at 12:28 AM, Doug Stewart <address@hidden> wrote:


On Wed, Nov 5, 2014 at 7:55 AM, Alasdair McAndrew <address@hidden> wrote:
I'm setting up a matrix of student marks; using NaNs for non-existent data: a question not attempted.  I'd like to be able to store this as ascii text outside of Octave, with a row looking something like

5 2 N 3 4 N N 3 6 4

the N's indicating questions not attempted.  I can read this into Octave with "fileread", and I get a long string, which I can then fiddle with to turn into numeric values and NaNs.  The function "dlmread" is more convenient, but converts all non-numeric data to zeros.

Is there an easy way to store NaNs in an ascii file, and how then can that file be best read into Ocatve?

Thanks,
Alasdair



a =

     1     2   NaN     4     6


>> save -ascii a.txt a
b=load('a.txt')
b =

     1     2   NaN     4     6

>>
--
http://www.facebook.com/alasdair.mcandrew https://plus.google.com/+AlasdairMcAndrew/posts https://www.linkedin.com/pub/alasdair-mcandrew/a/178/108 https://twitter.com/amca01 http://numbersandshapes.net

_______________________________________________
Help-octave mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/help-octave




--
DASCertificate for 206392




--
http://www.facebook.com/alasdair.mcandrew https://plus.google.com/+AlasdairMcAndrew/posts https://www.linkedin.com/pub/alasdair-mcandrew/a/178/108 https://twitter.com/amca01 http://numbersandshapes.net

reply via email to

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