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

Create a new vector - vector manipulation, Write single MATLAB statements t...

Write single MATLAB statements to create these vectors from any vector Z. You can use vector Z shown as a sample input. Create a single m-file script (non-function) to containing a

Simulte the operation of the system, People arrive at a microscope exhibit ...

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

Error in variables statements, Error in variables statements: Error: T...

Error in variables statements: Error: The expression in the left of equals sign is not a valid target for an assignment. >>  By placing a semicolon at the end of the sta

Polynomial fitting, how can i used loops instead of polyfit function

how can i used loops instead of polyfit function

Regression, can we use regression in bioinformatics toolbox?

can we use regression in bioinformatics toolbox?

Program to find the minimum total cost for the fence, A fence enclosure con...

A fence enclosure consists of a rectangle of length L and width 2 R , and a semicircle of radius R , as shown in Figure 1. The enclosure is to be built to have an area of 1600 m

Create a text file with simulated data, Create a text file with simulated d...

Create a text file with simulated data. Calculate an experimental y using the first function and some reasonable values for the parameters Add noise Save the x values and ca

Determine standard deviation, Find f(t) for each F(s): Problem: ...

Find f(t) for each F(s): Problem: Based on an examination given to a large class in which the maximum score is 100 points, assuming that 20 grades taken at random f

Matlab programming on johnson''s sequencing rule, i want matlab programming...

i want matlab programming on johnson''s sequencing rule

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