Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello. I am trying to call a function that generates a random number from a separate .m file in MATLAB and I am having trouble

Hello. I am trying to call a function that generates a random number from a separate .m file in MATLAB and I am having trouble in the area inside the red box shown in the picture. I am trying to set randomInt and a random integer that is generated in a separate function. I had trouble creating a random integer inside the sortGame file because the number would change every interation the program was run. Please help how I can fix this error in calling the randomNum function in my sortGame function. Thank you!!image text in transcribed

x randomNum.m X sortGame, m x random lNum.m x sort Game m function sort Game (userGuess) 1 function random Num (x) 3 x randi 00 disp (x) random m X x-random en 5 prompt. Please guess a number between 0 and 100 miser Guess-input (prompt) if rand miser Guess fprintf ('si is too low. In userGuess) i i 1 sort Game (use rGuess) scall recursively till too low 3 end 4 if rand Int userGuess fprint f ('si is too high in', userGuess); i i 1; sort Game user Guess) call recurs ivly till high number end if (randomInt user Guess) stop recursion when get guessed number fprint f You guessed si in si guesses In userGuess, i) 2 end 3 end

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

Students also viewed these Databases questions

Question

Developing and delivering learning that is integrated with the job.

Answered: 1 week ago

Question

Use of assessments to determine trainees learning styles.

Answered: 1 week ago

Question

7. Discuss the advantages of embedded learning.

Answered: 1 week ago