Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Simulation a function with random parameters

Subject: Simulation a function with random parameters

From: Abel

Date: 29 Jul, 2013 08:11:16

Message: 1 of 5

Hello,

I would like to simulate a function with random parameters. The function is named simulation4 and can be called by the following command :

simulation4(50,700,5000,4);

What I would like to do is then to write another function that would call simulation4 50 times for example and with random parameters. Each time it is called, I would write something in an .xls file.

Moreover I need to control the "randomness" : indeed I need first parameter to be a random number between 10 and 50, the second between 100 and 700, the third between 3000 and 5000 and finally the last between 1 and 16. I would like to avoid something like this :

simulation4(1.12,5.68,8.21,1.01)

Which, for some specifical reasons, would be useless.

Thanks.

Subject: Simulation a function with random parameters

From: Abel

Date: 29 Jul, 2013 09:39:11

Message: 2 of 5

Well I've managed to do something like this :

simulation4(round(10+40*rand()),round(100+600*rand()),round(3000+4000*rand()),round(1+16*rand()));

Subject: Simulation a function with random parameters

From: Chris

Date: 29 Jul, 2013 09:41:11

Message: 3 of 5

So do you want the parameters to be uniformly distributed or to have a (truncated) Gaussian distribution around a mean? And should some of the input be integer format?

Subject: Simulation a function with random parameters

From: Abel

Date: 29 Jul, 2013 09:51:13

Message: 4 of 5

Well thank you Chris for tour answer. In fact rounding like above is enough for my needs.

Subject: Simulation a function with random parameters

From: Steven_Lord

Date: 29 Jul, 2013 14:05:30

Message: 5 of 5



"Abel " <informatique8@aol.com> wrote in message
news:kt5duh$hqs$1@newscl01ah.mathworks.com...
> Well thank you Chris for tour answer. In fact rounding like above is
> enough for my needs.

If you want uniformly distributed integer values, use RANDI instead of ROUND
of RAND.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us