Question: 1. Matlab a) Write a function that generates a random number between 1 and 1000. Call the function rand_1000. This function doesn't take input. b)
1. Matlab
a) Write a function that generates a random number between 1 and 1000. Call the function rand_1000. This function doesn't take input.
b) Write a script which calls your rand_1000 function 10 times and sums the results.
c) Write a script that initiates a variable x to some random number between 1 and 10000. Thenrepeatdely or iteratively update x by alternately adding a random number between 1 and 1000 followed by subtracting a random number between 1 and 2000. Stop when x
0. Output x to the screen each iteration. Make use of rand_1000 whenever possible to save work.
d) The above function is random or stochastic. It will take a different number of iterations to exit each time you run it. What is the expected number of times it will run before it ends? In other words, if you ran it a billion times, counted the number of iterations each time, and averaged them together what would it be?
Matlab
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
