Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 ximage text in transcribed0. 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Select Healthcare Classification Systems And Databases

Authors: Katherine S. Rowell, Ann Cutrell

1st Edition

0615909760, 978-0615909769

More Books

Students also viewed these Databases questions