How do I reset the state of the MATLAB random variable generator from C code?

조회 수: 3 (최근 30일)
I have created a shared library from a MATLAB function that uses the RAND variable. I want to reset the random number generator from an external C program.

채택된 답변

MathWorks Support Team
MathWorks Support Team 2010년 1월 20일
To reset the random number generator from an external C code program, add the following function to your project:
function reset_rand
rand('state', 0)
When creating your shared library, add the above function to the list of MATLAB files to be compiled. Once the library is created, you can make a call to the following function to reset the random number generator:
mlfReset_rand()
If you are using MATLAB 6.1 or earlier, you can also use the mlfRand function call from MATLAB C Math library as follows to reset the random number generator:
mlfNRand(0,mxCreateString("state"), mlfScalar(0), NULL);

추가 답변 (0개)

카테고리

Help CenterFile 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