How to make elements in an array permanant

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

 채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 3월 27일

1 개 추천

You can save your array in a mat file

댓글 수: 1

Azzi Abdelmalek
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
James Tursa 2013년 3월 27일

0 개 추천

You could fix the seed used every time so you get the same stream of random numbers with each trial. See the rng function:

카테고리

도움말 센터 및 File Exchange에서 Random Number Generation에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by