OT: Anyone with MATLAB programming knowhow
#1
Burning Brakes
Thread Starter
Join Date: Nov 2001
Location: PA
Posts: 971
Likes: 0
Received 0 Likes
on
0 Posts
![Post](https://rennlist.com/forums/images/icons/icon1.gif)
I have no clue on how to use MATLAB. Never heard of it until I came to WVU.
Anyhow, I want to generate random numbers between the values 27 and 39 for 10000 trails.
when typing in rand(1,10000) you get a result of 10000 numbers that range between 0 and 1 and as stated above i need them for values between 27 and 39.
If ANYONE know how to do this and is willing to share their knowledge, by all means contact me...
email is travis.kirby@us.army.mil if you want to email me
thanks,
Travis
Anyhow, I want to generate random numbers between the values 27 and 39 for 10000 trails.
when typing in rand(1,10000) you get a result of 10000 numbers that range between 0 and 1 and as stated above i need them for values between 27 and 39.
If ANYONE know how to do this and is willing to share their knowledge, by all means contact me...
email is travis.kirby@us.army.mil if you want to email me
thanks,
Travis
#2
Three Wheelin'
Join Date: Oct 2001
Location: Seattle, WA
Posts: 1,805
Likes: 0
Received 0 Likes
on
0 Posts
![Post](https://rennlist.com/forums/images/icons/icon1.gif)
Well, this is sort of backasswards, and I've never used Matlab and may not understand your question, but this may work. I assume you are not dealing with integers.
Simply multiply your result by (39-27) and then add 27.
Example
random number is 0.5423
(0.5423 * (39-27)) + 27 = 33.5076
Simply multiply your result by (39-27) and then add 27.
Example
random number is 0.5423
(0.5423 * (39-27)) + 27 = 33.5076
#3
Rennlist Member
Join Date: May 2001
Location: North Of Chicago
Posts: 1,992
Likes: 0
Received 0 Likes
on
0 Posts
![Post](https://rennlist.com/forums/images/icons/icon1.gif)
Yikes!! MATLab and the horror of differential equations and arrays!!! I had pretty much wiped that stuff from my memory. You can check out their website at:
<a href="http://www.mathworks.com/access/helpdesk/help/techdoc/matlab.shtml" target="_blank">MATLab</a>
Under the functions-alphabetical it explains how to use the rand function.
From example 2 with your values:
a = 27; b = 39; 10000 => 100x100 array
x = a + (b-a) * rand(100)
x= your answer.
Ow..my brain hurts, I am going to sleep...
HTH
<a href="http://www.mathworks.com/access/helpdesk/help/techdoc/matlab.shtml" target="_blank">MATLab</a>
Under the functions-alphabetical it explains how to use the rand function.
From example 2 with your values:
a = 27; b = 39; 10000 => 100x100 array
x = a + (b-a) * rand(100)
x= your answer.
Ow..my brain hurts, I am going to sleep...
HTH
#4
Racer
Join Date: Jan 2002
Location: Norrköping, Sweden
Posts: 271
Likes: 0
Received 0 Likes
on
0 Posts
![Post](https://rennlist.com/forums/images/icons/icon1.gif)
Matlab is fun! You can create strange sounds with it and annoy your friends living next door
» fs=44100;
» t=(0
1/fs):10);
» s=sin(2*pi*50*t);
» soundsc(s,fs)
will give you 10 s of 50 Hz sound in your speakers
I think x=27+12*rand(1,10000); will do the job for you.
//Magnus
![Stick Out Tongue](https://rennlist.com/forums/images/smilies/tongue.gif)
» fs=44100;
» t=(0
![Frown](https://rennlist.com/forums/images/smilies/frown.gif)
» s=sin(2*pi*50*t);
» soundsc(s,fs)
will give you 10 s of 50 Hz sound in your speakers
![Big Grin](https://rennlist.com/forums/images/smilies/biggrin.gif)
I think x=27+12*rand(1,10000); will do the job for you.
//Magnus
#5
![Post](https://rennlist.com/forums/images/icons/icon1.gif)
That makes my head hurt! I don't even know how I got through diffiQ's wasted as I was most the time.
Sorry the only thing I have left in my head is fleeting bits of assmbler code and haunting thoughts of "who were those girls anyway?"!!
Magnus made me laugh though. Brought back a time when dealing with a pain of an architectural engineer in the dorm next door. Mix that with 400w's of drivability pushing a very faint 25hz through 4 18" woofers pointed directly at the dividing wall. . . . His entire finals weekend.
Sorry the only thing I have left in my head is fleeting bits of assmbler code and haunting thoughts of "who were those girls anyway?"!!
Magnus made me laugh though. Brought back a time when dealing with a pain of an architectural engineer in the dorm next door. Mix that with 400w's of drivability pushing a very faint 25hz through 4 18" woofers pointed directly at the dividing wall. . . . His entire finals weekend.
#6
Burning Brakes
Thread Starter
Join Date: Nov 2001
Location: PA
Posts: 971
Likes: 0
Received 0 Likes
on
0 Posts
![Post](https://rennlist.com/forums/images/icons/icon1.gif)
ok.........i have that 27+12*rand(1,10000) in my notes, but i was hoping there was a easier way....oh well
thanks guys...
and i'll be trying that sound matlab program....
space
thanks guys...
and i'll be trying that sound matlab program....
space