Random seed in Simulink

im new to Simulink so please be easy on me with u'r answers.
I need to generate a number with in the [1,5] values and i need the number to be different every simulation, is there any comand to generate a random seed and not get the same seed every simulation.
I know i can change the seed manual in the random blook, but this is not a good solution for my problem, i need the random to be "Monte Carlo" style.

Thank you.


  • There is a simulink block named [u]random number[/u]. It is in the simulink [u]sources[/u] library.
  • Sorry but your idea didnt work,
    I made a simple simulation that has only a random number block and a scope , I ran the simulation 3 times, each time the scope had shown the same 3 numbers.
    What i need is that in every simulation i'll get different numbers.

    Thank you.
  • Ok, you can use the [u]matlab function[/u] block and then the function [u]rand[/u] or [u]randn[/u]. It gives different results for different simulations.
  • Hi,
    im sorry but like ur last solution this one didnt work as well.
    I made a simple simulation that has an embedded matlab function blook
    and a scope, the matlab funtion i wrote was :
    function y = fcn()
    % This block supports the Embedded MATLAB subset.
    % See the help menu for details.

    y = rand(1);
    //end of function

    The scope had shown me the same result in each simulation i ran.

    Thank you.
  • Not the embedded matlab function, even if I think that it has to work well, but [u]MATLAB function[/u], and in the properties of the block you have to specify "rand" or "randn".
    I try this

    constant (1) --> Matlab function (rand) --> scope.

    It gives me always different values
  • Thank you, this solution is what i was looking for.

  • I'm glad I could help!
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!