Hello,I need a function as random in C language. Maybe you will say that i can call C function, but the effect is not the same in visual c++ tool. So, I need your help. thanks.
Asked
Active
Viewed 767 times
2 Answers
3
See the Noise library:
https://github.com/DLR-SR/Noise
It has some models and functions to generate random numbers.

Adrian Pop
- 4,034
- 13
- 16
-
-
http://book.xogeny.com/behavior/functions/external/ I implemented it by C languge – Laughing Apr 11 '16 at 08:14
1
If you are using Dymola
, you can use the function rand()
:
model rand_model
Real a(start=rand());
Real b(start=rand());
equation
when (sample(1,1)) then
a = rand();
b = rand();
end when;
end rand_model;
The function is not documented in the Dymola
user manual and it is no part of the modelica
standard. The output seems to be an integer between 0
and 32767
, seed seems to be constant.
Perhaps the implementation is given in the moutil.c file which is shipped with Dymola. But i'm not sure.

Richard Erickson
- 2,568
- 8
- 26
- 39

Lukas Exel
- 86
- 5