user3174907
user3174907

Reputation: 21

MATLAB: Need to replace all NaN in an array in matlab?

How can I replace all NaN in an array in matlab? I want to replace all NaN value with some infinite value. My code is shown below:

   Z=
          NaN
           NaN
      23.0490
        2.8444
          -Inf
       NaN
       NaN
       19.0081
        5.1412
       39.4275
    6.3174
      -Inf
       NaN
       NaN
   19.0081
    5.1412
   28.2539
    9.3265
   37.7239
   11.9736
  -16.4239
    9.3265
   -8.2900
  -25.6488
       NaN
       NaN

Upvotes: 0

Views: 302

Answers (1)

Shai
Shai

Reputation: 114796

Have you tried:

Z(isnan(Z)) = inf

Upvotes: 3

Related Questions