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

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

Posted Date: 10/19/2012 6:11:38 AM | Location : United States







Related Discussions:- Error-checking user input in the while loop, Assignment Help, Ask Question on Error-checking user input in the while loop, Get Answer, Expert's Help, Error-checking user input in the while loop Discussions

Write discussion on Error-checking user input in the while loop
Your posts are moderated
Related Questions
The mass of the spring-mass-damper system shown below was initially displaced by 1 meter to the right and then released. The subsequent acceleration of the mass was measured using


I have a file to be read in matlab which carries different columns in it. Each column has around 200000 readings in set of 2000. I want a code in a loop which gives stores each col

how to display any words to the edittor

can i post attachments of the assignment? and you do them for me?

A. Introduction The project consists of two parts. In the first part you are asked to perform some preliminary calculation and plotting, and to write the introduction for your

how to find absolute value of a number

Create a GUI that has A button to bring up a dialog to select a text file and read it in. Plot the x,y values on the GUI Have text entry values, one for each parameter, in which

Write a script to determine the volume of a pyramid, which is 1/3 * base * height, where the base is length * width. On time the user to enter values for the length, width, and th

Types: Each and every expression, or variable, has a type related with it. The MATLAB supports numerous types of values that are known as classes. A class is necessarily a com