Removing element of array at random

24 ビュー (過去 30 日間)
Ndugatuda Maxwell
Ndugatuda Maxwell 2021 年 12 月 31 日
コメント済み: Ndugatuda Maxwell 2021 年 12 月 31 日
I have a 200 x 1 matrix of random numbers and I want to remove 10 numbers from the array at random.
Here is sample data i used:
a = 0; %mean
b = 1; %standard deviation
random_num = b*randn(200,1)+a; %generates random numbers
How can I remove, at random 10 numbers from the random_num variable?

採用された回答

Stephen23
Stephen23 2021 年 12 月 31 日
a = 0;
b = 1;
rn = b*randn(200,1)+1;
ix = randperm(200,10) % indices of elements to remove
ix = 1×10
145 76 40 81 116 61 82 94 113 182
rn(ix) = []; % remove elements
  1 件のコメント
Ndugatuda Maxwell
Ndugatuda Maxwell 2021 年 12 月 31 日
Thank you Stephen. It helped!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by