performing without randi

17 visualizaciones (últimos 30 días)
kash
kash el 8 de Mzo. de 2012
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;

Respuestas (1)

Jan
Jan el 8 de Mzo. de 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.

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by