performing without randi
17 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Jan
on 8 Mar 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 Comments
See Also
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!