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 x0. 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started