How can I use a random seed continually ?
Show older comments
Hi I have a question about random seed. I want to use a two-random seed continually.
For example, when i=1, I use seed 1's first number in m-file and seed 2's first number in function. and next i=2, I want use seed 1's second number in m-file and seed 2's second number in function.
but below code is when i=1, I use seed 1's first number in m-file and seed 2's first number in function. and next i=2, I will use seed 2's second number in m-file and seed 2's third number in function.
This is pseudo code for understanding
-------------------------------------------------------------------------------------------
rng(1)
for i=1:100
A(i,1)=rand('unid',1)
B=(i,1)= function( A(i,1) )
% function y=function(x)
% rng(2)
% a=rand('unid',1)
% y=a + x
end
-------------------------------------------------------------------------------------------
How can I set the code? Thanks.
Answers (1)
Walter Roberson
on 12 Oct 2016
0 votes
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!