Notices
924/931/944/951/968 Forum Porsche 924, 924S, 931, 944, 944S, 944S2, 951, and 968 discussion, how-to guides, and technical help. (1976-1995)
Sponsored by:
Sponsored by:

OT: Anyone with MATLAB programming knowhow

Thread Tools
 
Search this Thread
 
Old 01-23-2003, 01:57 AM
  #1  
ThE sPaCeCoWbOy
Burning Brakes
Thread Starter
 
ThE sPaCeCoWbOy's Avatar
 
Join Date: Nov 2001
Location: PA
Posts: 971
Likes: 0
Received 0 Likes on 0 Posts
Post OT: Anyone with MATLAB programming knowhow

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
Old 01-23-2003, 02:02 AM
  #2  
Steve Lavigne
Three Wheelin'
 
Steve Lavigne's Avatar
 
Join Date: Oct 2001
Location: Seattle, WA
Posts: 1,805
Likes: 0
Received 0 Likes on 0 Posts
Post

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
Old 01-23-2003, 02:15 AM
  #3  
Riff
Rennlist Member
 
Riff's Avatar
 
Join Date: May 2001
Location: North Of Chicago
Posts: 1,992
Likes: 0
Received 0 Likes on 0 Posts
Post

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 =&gt; 100x100 array
x = a + (b-a) * rand(100)
x= your answer.

Ow..my brain hurts, I am going to sleep...

HTH
Old 01-23-2003, 05:32 AM
  #4  
Magnus
Racer
 
Magnus's Avatar
 
Join Date: Jan 2002
Location: Norrköping, Sweden
Posts: 271
Likes: 0
Received 0 Likes on 0 Posts
Post

Matlab is fun! You can create strange sounds with it and annoy your friends living next door

» fs=44100;
» t=(01/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
Old 01-23-2003, 06:18 AM
  #5  
D. Autry
Instructor
 
D. Autry's Avatar
 
Join Date: Jan 2003
Location: Colorado
Posts: 121
Likes: 0
Received 0 Likes on 0 Posts
Post

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.
Old 01-23-2003, 02:35 PM
  #6  
ThE sPaCeCoWbOy
Burning Brakes
Thread Starter
 
ThE sPaCeCoWbOy's Avatar
 
Join Date: Nov 2001
Location: PA
Posts: 971
Likes: 0
Received 0 Likes on 0 Posts
Post

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



Quick Reply: OT: Anyone with MATLAB programming knowhow



All times are GMT -3. The time now is 07:26 PM.