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