Error-checking user input in the while loop, MATLAB Programming

Assignment Help:

Error-Checking user input in the While Loop:

In many applications, whenever the user is prompted to enter anything, there is a valid range of values. When the user enters a wrong value, instead of having the program carry on with a wrong value, or just printing an error message, the program must repeat the prompt. The program must keep prompting the user, reading the value, and checking it, till the user enters a value which is in the right range. This is a very general application of a conditional loop, looping until the user properly enters a value in the program. This is known as error-checking.

For illustration, the script below prompts the user to enter a positive number, and loops to print an error message and repeat the prompt till the user finally enter a positive number.

1754_Error-checking user input in the while loop.png


Related Discussions:- Error-checking user input in the while loop

Simple related plot functions, Simple Related Plot Functions: The othe...

Simple Related Plot Functions: The other functions which are useful in customizing plots are the figure, clf, hold, leg-end, and grid. The short description of such functions

Matrices of random numbers, Matrices of random numbers: The Matrices o...

Matrices of random numbers: The Matrices of random numbers can be generated using the rand and randint functions. The first two arguments in the randint function identify the

Illustration of output statements, Illustration of Output statements: ...

Illustration of Output statements: For illustration, >> disp('Hello') Hello >> disp(4^3)   64 The formatted output can be printed to the screen by using the fpr

Creating row vectors, Creating row Vectors: There are many ways to gen...

Creating row Vectors: There are many ways to generate row vector variables. The most important way is to put the values which you want in the vector in square brackets, separa

Monte carlo simulation, i need help with a monte carlo simulation. I have m...

i need help with a monte carlo simulation. I have most of the code, but I can''t get it to plot correctly

EMG, How to make EMG analysis by Matlab?

How to make EMG analysis by Matlab?

Homework, Given , provide solutions for the following systems of equations ...

Given , provide solutions for the following systems of equations a) , 1.0 10.5 0.5 9 0.5 3.25 5.25 2.5 2 13 5 6 ? ? ? ? ? ? ? ? ? ? ? A ? ? ? ? ? ? ? ? ? ? ? ? 3 7 16 b b) , 1.0 10

Create a super mario brothers game application, Create a Super Mario Brothe...

Create a Super Mario Brothers game in Matlab. The lines of codes do not matter. But, The requirements are: REQUIREMENTS: Modular design and implementation Algorithm docu

Error-checking user input in the while loop, Error-Checking user input in t...

Error-Checking user input in the While Loop: In many applications, whenever the user is prompted to enter anything, there is a valid range of values. When the user enters a wr

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd