[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Treating -999 values in ASCII as missing
From: |
Francesco Potortì |
Subject: |
Re: Treating -999 values in ASCII as missing |
Date: |
Tue, 07 Aug 2012 19:21:01 +0200 |
>I have some data stored in ASCII files which I use 'load' command to read.
>In those files, missing values are stored as -999.
>
>I would like to know how do I say to Octave, at read time, that those -999
>values must be treated as missing values.
>
>Is there a simple function to do this?
>
>I've searched this, but found nothing. The best I can think is to span all
>the data with a for-loop, checking every matrix element and replacing it
>when was the case.
If you have a matrix A and want to replace all -999 values with
something else (say, 0), you do:
A(A==-999) = 0
For doing statistical computations, you can use NA as a placeholder for
missing values. To compute the mean of a vector V ignoring NA values,
you do
nanmean(A)
This ignores all NaN values, and NA is a particular NaN values, so it
is ignored. There are some other functions that ignore NaN values,
specifically nanmax, nanmedian, nanmin, nanstd, nansum, nanvar.
--
Francesco Potortì (ricercatore) Voice: +39.050.315.3058 (op.2111)
ISTI - Area della ricerca CNR Mobile: +39.348.8283.107
via G. Moruzzi 1, I-56124 Pisa Fax: +39.050.315.2040
(entrance 20, 1st floor, room C71) Web: http://fly.isti.cnr.it