Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MATLAB: 1. Write a function called problem1 that continuously generates one random integer at a time until it finds a number that is greater than

MATLAB:

1. Write a function called problem1 that continuously generates one random integer at a time until it finds a number that is greater than the number (a positive integer < 1000) that is passed as an input argument to the function. The function returns the number of random integers that it had to generate. This problem requires that you generate random integers using randi. Use 1000 as the maximum integer value that randi should generate. Also, make sure you don't generate a random integer and not use it. The grader assumes that all generated values are used. Hence, generate one random integer during each iteration. To allow for the grader to generate the same sequence of random values as your function, you are required to call the rng function in your solution before you make any call to randi. The "seed" for the rng function will be passed as an input argument. Suppose the input argument is named seed, you must have the following line of code in your function. It should be written only once in your function and it is highly recommended that this is the first line in your function body. rng(seed); The function should accept two input arguments (in this order): 1) the seed for the random number generator and 2) the number that must be exceeded by any generated random integer value. As noted above, the function should return one output argument representing the number of random integer values that was generated. You are required to use a while-loop for this function. Hence, the use of a for-loop is prohibited. For example, the call problem1(797267, 500) should return 5, because it should have generated the following sequence of five random numbers: 256, 196, 342, 500, and 903. If you are not getting the same output, try printing the random integers as you are generating them.

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

DB2 Universal Database V7.1 Application Development Certification Guide

Authors: Steve Sanyal, David Martineau, Kevin Gashyna, Michael Kyprianou

1st Edition

ISBN: 0130913677, 978-0130913678

More Books

Students also viewed these Databases questions

Question

Solve: ady- ydx (x + y) dx

Answered: 1 week ago