1 and 0 matrix
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Offroad Jeep
am 5 Mai 2015
Bearbeitet: Offroad Jeep
am 24 Mai 2015
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...........
0 Kommentare
Akzeptierte Antwort
Andrei Bobrov
am 5 Mai 2015
n = 5; % size your matrix
k = 10; % your percent
out = zeros(n);
out(randperm(n^2,ceil(n^2*k/100))) = 1;
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!