performing without randi
17 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I ahave a code below,where A is a matrix,if i run this i get different anwer for eacg time,please tell how to perform without using randii function,
the code below is used to replace some values by zero,like this i need 10 matrices
please help
n = numel(A);
A1_10 = repmat(A,[1,1,10]);
t = ones(size(A));
for j1 = 1:size(A1_10,3)
p = t;
p(randi(n,600,1)) = 0;
A1_10(:,:,j1) = A1_10(:,:,j1).*p;
0 Kommentare
Antworten (1)
Jan
am 8 Mär. 2012
The code set some random elements to zero. If you want to omit randi, what should be done instead?
If you want to get the same result for each run, initialize the randon number generator, see help rand or doc randi - the exact proceeding depends on the Matlab release.
0 Kommentare
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!