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
how to find absolute value of a number

Passing Multiple Arguments: In many situaion it is essential to pass more than one argument to the function. For illustration, the volume of a cone is given by here r

Scripts to Produce and Customize the Simple Plots: The MATLAB has many graphing capabilities. In most cases, customizing plots are desired and this is the simplest to accompli

Solve for unknowns 'x' and 'y' from Equations (1) and (2) using MATLAB. (However, if MATLAB is not the appropriate software to solve these two simultaneous equations, please sugges

The following four 4 equations are needed to be plotted as CONTOUR lines on the axes space (C, T) where C is the horizontal axis, and T is the vertical axis. Contour lines for

Produce a random real number: To produce a random real number in the range from low to high, at first create the variables low and high. And then, use the expression rand*(hig

1. Enter the 3×4 matrix Let a ij denote the entry of A in the ith row and jth column. Use Matlab to compute the following : (a) a 13 + a 32 (b) Three times the

2)''dbcont'' command for debugging is used to Select one: a. Continue normal code execution from the debug prompt. b. List all breakpoints. c. Execute (step) one or more lines

Implement a MatLab function to calculate y.  The function should take two input arguments 1) A vector of parameters In the above example this would be of length 3, the first

This can be done from the command line or from a makefile. You require a script (filename.m). Just type at the command line, or contain in the makefile: matlab