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
Functions with Local Variables: The functions we have seen faraway have been very easy. Though, in many situations the computations in a function are more complex, and may nee

People arrive at a microscope exhibit at a rate of one every 8+/- 2 minutes. Only one person can see the exhibit at a time. It takes 5 +/- 2 minutes to see the exhibit. A person

How to design a FIR filter using ANFIS in MATLAB

#defining matrix using only special commands

A file houseafford.dat stores on its three lines years, median incomes and median home prices for a city. The dollar amounts are in thousands. For example, it might look like this:

#quest121ion..

i want to extract an image from its background in matlab..the image is a binary image

design a rc phase shift oscillator for a particular frequency of oscillation and generate a sinusoidal signal

Looping Statements: Consider the problem of computing the area of a circle with radius of 0.3 centimeters-a MATLAB program certainly is not required to do that; you would use

1. Assume that there exists a surface that can be modeled with the equation:  z = e-(x 2 + y 2 ).  a) Calculate ∇z at the point (x = 0, y = 0). b) In addition, use MATLAB to