MATLAB Answers

Insert certain percentages of missing values in a dataset

10 views (last 30 days)
MOHAMAD FAIZ DZULKALNINE
MOHAMAD FAIZ DZULKALNINE on 25 Feb 2021
Commented: KSSV on 25 Feb 2021
I have a dataset with a certain dimension. For example 600x10. I want to insert missing values randomly in the dataset in certain percentages such as 10% or 20%.
Can anyone help please? Thank you.

Accepted Answer

KSSV
KSSV on 25 Feb 2021
Edited: KSSV on 25 Feb 2021
A = rand(600,10) ; % demo data
N = numel(A) ; % number of elements
idx = randperm(N,10/100*N) ; % get 10% of data indices randomly
A(idx) = NaN ; % replace the indices with NaN, these are missing

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by