COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### replace missing value to nan

• Follow

```Dear All
I got  sea surface high from observation is 3d then converted to my grid point by interp2 function. The missing valu "1.8447e+19" is include both of them.
I try fill missing value with "nan" by wrote for example following code so I couldn't remove missing value. Please guide me what I do.
nn=size(zeta);
nn(1)=12; nn(2)=212; nn(3)=236;
for i = 1 : nn(1)
for j = 1 : nn(2)
for k = 1 : nn(3)
if zeta(i,j,k)<1.84467440737096e+19;
ssh(i,j,k)=zeta(i,j,k);
else
ssh(i,j,k)=nan;
end
end
end

Best Regards
F.Daryabor
```
 0

```One Line...

zeta(zeta>=1.84467440737096e+19)=nan;

Matlab is awesome

"FARSHID " <fdaryabor@gmail.com> wrote in message <i7i1u8\$m6o\$1@fred.mathworks.com>...
> Dear All
> I got  sea surface high from observation is 3d then converted to my grid point by interp2 function. The missing valu "1.8447e+19" is include both of them.
> I try fill missing value with "nan" by wrote for example following code so I couldn't remove missing value. Please guide me what I do.
>  nn=size(zeta);
> nn(1)=12; nn(2)=212; nn(3)=236;
> for i = 1 : nn(1)
>     for j = 1 : nn(2)
>         for k = 1 : nn(3)
>             if zeta(i,j,k)<1.84467440737096e+19;
>                 ssh(i,j,k)=zeta(i,j,k);
>                   else
>                 ssh(i,j,k)=nan;
>             end
>        end
> end
>
> Best Regards
> F.Daryabor
```
 0

```Dear Patrick
It doesn't work I used it before.
Really tested different ways but didn't work none.
Best Regards

Sent details of data as following:

nc = netcdf('msla_h.nc', 'noclobber');
if isempty(nc), return, end

%% Global attributes:

nc.title = ncchar(''SSALTO/DUACS - NRT MSLA - Merged Product'');
nc.institution = ncchar('' '');
nc.references = ncchar('' '');
nc.source = ncchar('' '');
nc.Conventions = ncchar(''CF-1.0'');
nc.history = ncchar(''Data extracted from dataset http://opendap.aviso.oceanobs.com/thredds/dodsC/dataset-duacs-nrt-over30d-global-merged-msla-h'');
nc.time_min = ncdouble(518616);
nc.time_max = ncdouble(527376);
nc.julian_day_unit = ncchar(''hours since 1950-01-01'');
nc.latitude_min = ncdouble(-20.0050076288087);
nc.latitude_max = ncdouble(30.0889553945206);
nc.longitude_min = ncdouble(89.999999999991);
nc.longitude_max = ncdouble(129.999999999987);

%% Dimensions:

nc('time') = 366;
nc('NbLatitudes') = 157;
nc('NbLongitudes') = 121;

%% Variables and attributes:

nc{'time'} = nclong('time'); %% 366 elements.
nc{'time'}.units = ncchar(''hours since 1950-01-01'');
nc{'time'}.CoordinateAxisType_ = ncchar(''Time'');
nc{'time'}.valid_min = nclong(518616);
nc{'time'}.valid_max = nclong(527376);
nc{'time'}.axis = ncchar(''T'');
nc{'time'}.long_name = ncchar(''time'');
nc{'time'}.standard_name = ncchar(''time'');

nc{'NbLatitudes'} = ncdouble('NbLatitudes'); %% 157 elements.
nc{'NbLatitudes'}.FillValue_ = ncdouble(1.84467440737096e+019);
nc{'NbLatitudes'}.long_name = ncchar(''Latitudes'');
nc{'NbLatitudes'}.units = ncchar(''degrees_north'');
nc{'NbLatitudes'}.CoordinateAxisType_ = ncchar(''Lat'');
nc{'NbLatitudes'}.valid_min = ncdouble(-20.0050076288087);
nc{'NbLatitudes'}.valid_max = ncdouble(30.0889553945206);
nc{'NbLatitudes'}.axis = ncchar(''Y'');
nc{'NbLatitudes'}.standard_name = ncchar(''latitude'');

nc{'NbLongitudes'} = ncdouble('NbLongitudes'); %% 121 elements.
nc{'NbLongitudes'}.FillValue_ = ncdouble(1.84467440737096e+019);
nc{'NbLongitudes'}.long_name = ncchar(''Longitudes'');
nc{'NbLongitudes'}.units = ncchar(''degrees_east'');
nc{'NbLongitudes'}.CoordinateAxisType_ = ncchar(''Lon'');
nc{'NbLongitudes'}.valid_min = ncdouble(89.999999999991);
nc{'NbLongitudes'}.valid_max = ncdouble(129.999999999987);
nc{'NbLongitudes'}.axis = ncchar(''X'');
nc{'NbLongitudes'}.standard_name = ncchar(''longitude'');

nc{'Grid_0001'} = ncfloat('time', 'NbLongitudes', 'NbLatitudes'); %% 6952902 elements.
nc{'Grid_0001'}.CoordinateAxes_ = ncchar(''time NbLongitudes NbLatitudes '');
nc{'Grid_0001'}.FillValue_ = ncfloat(1.84467440737096e+019);
nc{'Grid_0001'}.long_name = ncchar(''H'');
nc{'Grid_0001'}.units = ncchar(''cm'');

endef(nc)
close(nc)

"Patrick " <phooker@dgigeoscience.com> wrote in message <i7i78s\$bt7\$1@fred.mathworks.com>...
> One Line...
>
> zeta(zeta>=1.84467440737096e+19)=nan;
>
> Matlab is awesome
>
> "FARSHID " <fdaryabor@gmail.com> wrote in message <i7i1u8\$m6o\$1@fred.mathworks.com>...
> > Dear All
> > I got  sea surface high from observation is 3d then converted to my grid point by interp2 function. The missing valu "1.8447e+19" is include both of them.
> > I try fill missing value with "nan" by wrote for example following code so I couldn't remove missing value. Please guide me what I do.
> >  nn=size(zeta);
> > nn(1)=12; nn(2)=212; nn(3)=236;
> > for i = 1 : nn(1)
> >     for j = 1 : nn(2)
> >         for k = 1 : nn(3)
> >             if zeta(i,j,k)<1.84467440737096e+19;
> >                 ssh(i,j,k)=zeta(i,j,k);
> >                   else
> >                 ssh(i,j,k)=nan;
> >             end
> >        end
> > end
> >
> > Best Regards
> > F.Daryabor
```
 0

```"FARSHID " <fdaryabor@gmail.com> wrote in message <i7imio\$9c4\$1@fred.mathworks.com>...
> Dear Patrick
> It doesn't work I used it before.
> Really tested different ways but didn't work none.
> Best Regards

> > One Line...
> >
> > zeta(zeta>=1.84467440737096e+19)=nan;
> >
> > Matlab is awesome
> >

%Try:
SSH = zeta;
SSH(zeta>=1.84467440737096e+19) = nan;
```
 0

```"Sean " <sean.dewolski@nospamplease.umit.maine.edu> wrote in message <i7ineh\$69j\$1@fred.mathworks.com>...
> "FARSHID " <fdaryabor@gmail.com> wrote in message <i7imio\$9c4\$1@fred.mathworks.com>...
> > Dear Patrick
> > It doesn't work I used it before.
> > Really tested different ways but didn't work none.
> > Best Regards
>
> > > One Line...
> > >
> > > zeta(zeta>=1.84467440737096e+19)=nan;
> > >
> > > Matlab is awesome
> > >
>
> %Try:
> SSH = zeta;
> SSH(zeta>=1.84467440737096e+19) = nan;
Dear Patrick
Still it doesn't work.
Do you remember any way because tried different way.
Best Regards
F.Daryabor

```
 0

```"FARSHID " <fdaryabor@gmail.com> wrote in message <i7k1ma\$cq\$1@fred.mathworks.com>...
> "Sean " <sean.dewolski@nospamplease.umit.maine.edu> wrote in message <i7ineh\$69j\$1@fred.mathworks.com>...
> > "FARSHID " <fdaryabor@gmail.com> wrote in message <i7imio\$9c4\$1@fred.mathworks.com>...
> > > Dear Patrick
> > > It doesn't work I used it before.
> > > Really tested different ways but didn't work none.
> > > Best Regards
> >
> > > > One Line...
> > > >
> > > > zeta(zeta>=1.84467440737096e+19)=nan;
> > > >
> > > > Matlab is awesome
> > > >
> >
> > %Try:
> > SSH = zeta;
> > SSH(zeta>=1.84467440737096e+19) = nan;
> Dear Patrick
> Still it doesn't work.
> Do you remember any way because tried different way.
> Best Regards
> F.Daryabor
>

Can you tell us what you mean when you say "it doesn't work".

Is there an error message?
Does it execute and some large values get changed to NaN but not all of them?

SSH = zeta;
SSH(zeta>=1.844e+19) = nan;

Ross
```
 0

```"Ross W" <rosswoodskiwi@hotmail.com> wrote in message <i7k3d6\$h0k\$1@fred.mathworks.com>...
> "FARSHID " <fdaryabor@gmail.com> wrote in message <i7k1ma\$cq\$1@fred.mathworks.com>...
> > "Sean " <sean.dewolski@nospamplease.umit.maine.edu> wrote in message <i7ineh\$69j\$1@fred.mathworks.com>...
> > > "FARSHID " <fdaryabor@gmail.com> wrote in message <i7imio\$9c4\$1@fred.mathworks.com>...
> > > > Dear Patrick
> > > > It doesn't work I used it before.
> > > > Really tested different ways but didn't work none.
> > > > Best Regards
> > >
> > > > > One Line...
> > > > >
> > > > > zeta(zeta>=1.84467440737096e+19)=nan;
> > > > >
> > > > > Matlab is awesome
> > > > >
> > >
> > > %Try:
> > > SSH = zeta;
> > > SSH(zeta>=1.84467440737096e+19) = nan;
> > Dear Patrick
> > Still it doesn't work.
> > Do you remember any way because tried different way.
> > Best Regards
> > F.Daryabor
> >
>
> Can you tell us what you mean when you say "it doesn't work".
>
> Is there an error message?
> Does it execute and some large values get changed to NaN but not all of them?
>
>
> SSH = zeta;
> SSH(zeta>=1.844e+19) = nan;
>
> Ross

Dear Ross
Yes it execute but the large values doesn't change to NaN.
Best Regards
F.Daryabor
```
 0

```"FARSHID " <fdaryabor@gmail.com> wrote in message <i7l2pu\$o6o\$1@fred.mathworks.com>...
> "Ross W" <rosswoodskiwi@hotmail.com> wrote in message <i7k3d6\$h0k\$1@fred.mathworks.com>...
> > "FARSHID " <fdaryabor@gmail.com> wrote in message <i7k1ma\$cq\$1@fred.mathworks.com>...
> > > "Sean " <sean.dewolski@nospamplease.umit.maine.edu> wrote in message <i7ineh\$69j\$1@fred.mathworks.com>...
> > > > "FARSHID " <fdaryabor@gmail.com> wrote in message <i7imio\$9c4\$1@fred.mathworks.com>...
> > > > > Dear Patrick
> > > > > It doesn't work I used it before.
> > > > > Really tested different ways but didn't work none.
> > > > > Best Regards
> > > >
> > > > > > One Line...
> > > > > >
> > > > > > zeta(zeta>=1.84467440737096e+19)=nan;
> > > > > >
> > > > > > Matlab is awesome
> > > > > >
> > > >
> > > > %Try:
> > > > SSH = zeta;
> > > > SSH(zeta>=1.84467440737096e+19) = nan;
> > > Dear Patrick
> > > Still it doesn't work.
> > > Do you remember any way because tried different way.
> > > Best Regards
> > > F.Daryabor
> > >
> >
> > Can you tell us what you mean when you say "it doesn't work".
> >
> > Is there an error message?
> > Does it execute and some large values get changed to NaN but not all of them?
> >
> >
> > SSH = zeta;
> > SSH(zeta>=1.844e+19) = nan;
> >
> > Ross
>
> Dear Ross
> Yes it execute but the large values doesn't change to NaN.
> Best Regards
> F.Daryabor

So then maybe the problem is that the code is testing for equality on a floating point number.

Does this coded help?
SSH = zeta;
SSH(zeta>=1.844e+19) = nan;

Ross
```
 0
Reply rosswoodskiwi (55) 9/26/2010 12:52:04 AM

```"Ross W" <rosswoodskiwi@hotmail.com> wrote in message
> So then maybe the problem is that the code is testing for equality on a floating point number.
>
> Does this coded help?
> SSH = zeta;
> SSH(zeta>=1.844e+19) = nan;
>
> Ross

Try Ross's code, and before you write back, run this and TELL WHAT IS RETURNED:

class(SSH)
max(SSH(:))
```
 0

```"Matt Fig" <spamanon@yahoo.com> wrote in message <i7m67v\$rj3\$1@fred.mathworks.com>...
> "Ross W" <rosswoodskiwi@hotmail.com> wrote in message
> > So then maybe the problem is that the code is testing for equality on a floating point number.
> >
> > Does this coded help?
> > SSH = zeta;
> > SSH(zeta>=1.844e+19) = nan;
> >
> > Ross
>
>
> Try Ross's code, and before you write back, run this and TELL WHAT IS RETURNED:
>
> class(SSH)
> max(SSH(:))
Dear Ross
class and max val as following:
>> class(SSH)

ans =

double

>> max(SSH(:))

ans =

1.8447e+019
Best Regards
F.Daryabo
```
 0
Reply fdaryabor (3) 9/26/2010 3:34:04 PM

```
"FARSHID " <fdaryabor@gmail.com> wrote in message
news:i7k1ma\$cq\$1@fred.mathworks.com...
> "Sean " <sean.dewolski@nospamplease.umit.maine.edu> wrote in message
> <i7ineh\$69j\$1@fred.mathworks.com>...
>> "FARSHID " <fdaryabor@gmail.com> wrote in message
>> <i7imio\$9c4\$1@fred.mathworks.com>...
>> > Dear Patrick
>> > It doesn't work I used it before.
>> > Really tested different ways but didn't work none.
>> > Best Regards
>>
>> > > One Line...
>> > >
>> > > zeta(zeta>=1.84467440737096e+19)=nan;
>> > >
>> > > Matlab is awesome
>> > >
>>
>> %Try:
>> SSH = zeta;
>> SSH(zeta>=1.84467440737096e+19) = nan;
> Dear Patrick Still it doesn't work.
> Do you remember any way because tried different way.

Lower your threshold.  The elements of zeta may _be displayed_ as that exact
number but the actual value may be smaller.

If there's a big gap between the largest "correct value" and the smallest
"missing value" choose something in the middle of that gap, rather than
choosing what you think is the exact smallest "missing value".

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
http://www.mathworks.com

```
 0
Reply slord (13272) 9/27/2010 3:20:25 AM

10 Replies
404 Views

Similiar Articles:

7/23/2012 6:52:49 AM