How to replace missing data with a random value in the statistical distribution

2 ビュー (過去 30 日間)
vedesh Mohit
vedesh Mohit 2018 年 4 月 2 日
回答済み: Birdman 2018 年 4 月 2 日
I have a vector x=[1 NaN 2 3 NaN 4 NaN NaN NaN 5 7 9 3 0 23 9 8 ]; I would like to know if there is a way to randomly select a known value from x to replace only the missing values (NaN's) in x.

採用された回答

Birdman
Birdman 2018 年 4 月 2 日
x(isnan(x))=randsample(x(~isnan(x)),1)

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by