MATLAB coder - can't get the 'coderand' .exe to work correctly
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
michael brewin
el 4 de Mayo de 2018
Comentada: michael brewin
el 11 de Feb. de 2019
Hi. I'm running MATLAB C-coder for the first time, running through the 'coderand' example.
https://uk.mathworks.com/help/releases/R2015b/coder/ug/ standalone-c-c-executables-from-matlab-code.html
It works to produce C source code, (which is not overly clear) a MEX file and an executable. The MEX file works fine
Trial>> coderand_mex
ans =0.2785
Trial>> coderand_mex
ans =0.5469
Trial>> coderand_mex
ans =0.9575
but the .exe file doesn't seem to work, running inside MATLAB or a DOS cmd window. It produces the same number each time its ran
C:\ALL\SOAR\MATLAB_DEV\coder_play>coderand.exe
coderand=0.814724
C:\ALL\SOAR\MATLAB_DEV\coder_play>coderand.exe
coderand=0.814724
C:\ALL\SOAR\MATLAB_DEV\coder_play>coderand.exe
coderand=0.814724
I set the tool t build for MATLAB Windows Host and the Compiler to MinGW64 (I know this can cross compile too), but say it was creating a Linux binary, I would expect a .bin file output and I would not expect it to run.
(i) Can somebody explain what settings I have missed or wrong. (ii) Can somebody explain the some basis to the source code generation, I know that generating 'true' random numbers is something of a science topic The .exe produced is 61K, I would expect something a lot less.
(iii) It would be re-assuring if this example included some output too. I have covered many aspects of MATLAB & its toolboxes and add-ons in recent weeks and this is the first time that I've fully stumbled
Thanks, Mike B
4 comentarios
Jan
el 16 de Mayo de 2018
You do not have to bookmark the "Contact Us" link, because you find it on all pages of the MathWorks sites.
Respuesta aceptada
Jan
el 16 de Mayo de 2018
To get a documentation about rand, see doc rand. At the bottom there is the link: Why Do Random Numbers Repeat After Startup?. There you find the example:
If you want to avoid repeating the same random number arrays when
MATLAB restarts, then execute the command,
rng('shuffle');
Insert this before r = rand().
4 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Startup and Shutdown en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!