how to replaces NaN's with a corresponding vector?

1 回表示 (過去 30 日間)
vedesh Mohit
vedesh Mohit 2018 年 4 月 2 日
回答済み: Walter Roberson 2018 年 4 月 2 日
I have two vectors x=[1 NaN 2 3 NaN 4 NaN NaN NaN 5 ]; y=[10 11 11 6 8 9 7 2 29 93 ]; I would like to know if there is a way to replace only the missing values (NaN's) in x with the corresponding value in the vector y?

採用された回答

Walter Roberson
Walter Roberson 2018 年 4 月 2 日
mask = isnan(x)
x(mask) = y(mask)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNaNs についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by