フィルターのクリア

1 and 0 matrix

1 回表示 (過去 30 日間)
Offroad Jeep
Offroad Jeep 2015 年 5 月 5 日
編集済み: Offroad Jeep 2015 年 5 月 24 日
Hi All,..
I want to generate a n by n matrix with 1 and 0 . this matrix should have 10 percent zeros.... in some we cant get exact 10 so + or - 1 or 2 percent will be ok...........

採用された回答

Andrei Bobrov
Andrei Bobrov 2015 年 5 月 5 日
n = 5; % size your matrix
k = 10; % your percent
out = zeros(n);
out(randperm(n^2,ceil(n^2*k/100))) = 1;
  1 件のコメント
Offroad Jeep
Offroad Jeep 2015 年 5 月 5 日
thanks...........

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by