How to make elements in an array permanant
1 次查看(过去 30 天)
显示 更早的评论
I'm creating function that has a random array using randperm. Is there a way to fix the order of the elements in the array even when I run it several times? Every time I use the function, a new array will be produced. I want the function to be so that the randperm will only run once no matter how many times I click 'run'. Thanks
0 个评论
采纳的回答
Azzi Abdelmalek
2013-3-27
You can save your array in a mat file
1 个评论
Azzi Abdelmalek
2013-3-27
编辑:Azzi Abdelmalek
2013-3-27
Or
stream = RandStream('twister','Seed',0); % 'twister' is a generator
randperm(stream,5)
更多回答(1 个)
James Tursa
2013-3-27
You could fix the seed used every time so you get the same stream of random numbers with each trial. See the rng function:
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!