ENGRMAE 10 Lecture Notes - Lecture 13: Printf Format String

27 views7 pages

Document Summary

The rand( ) function generates random numbers between 0 and 1 that are distributed uniformly (all numbers are equally probable). After execution: number1 = 0. 42932 number2 = 0. 29074. If you want to generate random numbers from 0 to 10, you multiply the random number by 10. Example: multfactor = 10; randomarray = rand(1,5) multfactor*randomarray. If you want to generate n random numbers from a to b, use the following formula: (b-a) makes the difference between the lowest and highest random number the same as the difference between a and b. A + adjusts the lower part of the random number range to a. A = 5; b = 10; randomarray = a + (b-a)*rand(1,5); If you want to generate random integers from a to b in matlab, you can use the randi( ) function. However, this function does not exist in octave, so let s create our own random integer generator.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents