Matlab

Moderators: None (Apply to moderate this forum)
Number of threads: 1471
Number of posts: 2147

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Random seed in Simulink Posted by tako_bell on 7 Apr 2009 at 12:55 AM
Hi,
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.
Report
Re: Random seed in Simulink Posted by giug on 7 Apr 2009 at 1:11 AM
There is a simulink block named random number. It is in the simulink sources library.
Report
Re: Random seed in Simulink Posted by tako_bell on 7 Apr 2009 at 1:41 AM
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.
Report
Re: Random seed in Simulink Posted by giug on 7 Apr 2009 at 2:10 AM
Ok, you can use the matlab function block and then the function rand or randn. It gives different results for different simulations.
Report
Re: Random seed in Simulink Posted by tako_bell on 7 Apr 2009 at 2:27 AM
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.
Report
Re: Random seed in Simulink Posted by giug on 7 Apr 2009 at 2:36 AM
Not the embedded matlab function, even if I think that it has to work well, but MATLAB function, 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
Report
Re: Random seed in Simulink Posted by tako_bell on 7 Apr 2009 at 2:51 AM
Thank you, this solution is what i was looking for.
:)

Report
Re: Random seed in Simulink Posted by giug on 7 Apr 2009 at 3:06 AM
I'm glad I could help!



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.