Why does my compiled RAND function give the same values every time I run my MATLAB-generated standalone application?
古いコメントを表示
I tried to compile the code below to an executable:
function myrand
a=rand(4,1);
disp(a)
When I run the executable, the RAND function always returns the same set of numbers. However, if I run the code in MATLAB, the function gives different results when I call it repeatedly.
The same thing happens if I generate the executable with the Matlab Coder.
採用された回答
その他の回答 (1 件)
Greg
2018 年 10 月 24 日
In R2013a, "getDefaultStream" was replaced by "getGlobalStream" for the RandStream. Prior to that, it generated warnings indicating its eventual removal, but it began erroring in R2013a. For releases R2013a - R2018b (possibly later, but R2018b is the latest at time of writing), use:
reset(RandStream.getGlobalStream,sum(100*clock));
For releases prior to R2013a, see the other answer.
カテゴリ
ヘルプ センター および File Exchange で Application Deployment についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!