Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

To be completed in MatLab. Just having trouble formatting loops and user input p

ID: 3278552 • Letter: T

Question

To be completed in MatLab.

Just having trouble formatting loops and user input properly within Matlab. I'm familar with several C languages so i'm not new to Loops and their general format only how they are used in Matlab i'm having some trouble with.

Thanks in advance

Write a script that prompts users to enter a value between 2 to 5 inclusive, then it continuously generates random numbers (between 0 and 10) (once per half second) until the random number is greater than the entered value. Finally, the script display the number of running time. Your program should show: If user enters incorrect values, inform them and ask for a new value again When user enters a right number, generate random numbers (between 0 and 10) (once per half second) until the random number is greater than the entered value. You should display the random values every time they are generated Display the number of time that the loop has run until the random number is greater than the entered value

Explanation / Answer

The matlab code is mentioned below:

%===========================================================

clear all

input_no = 0;
while input_no > 5 || input_no < 2
input_no = input('Enter the number? ');
end

no_loop = 0;
for loop = 1:input_no
a = rand()*10
if (a<loop)
no_loop = no_loop+1;
pause(0.5);
end
if (a>loop)
break;
end
end
disp(no_loop);

%=======================================================================

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote