performing without randi

17 次查看(过去 30 天)
kash
kash 2012-3-8
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;

回答(1 个)

Jan
Jan 2012-3-8
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.

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by