Matlab program - error-checking for integers, MATLAB in Mathematics

Error-checking for integers:

illustrations of running this script as shown below:

>> readoneint

Enter an integer: 9.5

Invalid! Enter an integer: 3.6

Invalid! Enter an integer: -11

Thanks, you entered a -11

>> readoneint

Enter an integer: 5

Thanks, you entered a 5

Putting these ideas altogether, the script below loops until the user properly enters a positive integer. There are two sections to the condition, as the value should be positive and should be an integer.

2454_Error-Checking for Integers.png

>> readoneposint

Enter a positive integer: 5.5

Invalid! Enter a positive integer: -4

Invalid! Enter a positive integer: 11

Thanks, you entered a 11

Posted Date: 10/19/2012 6:17:05 AM | Location : United States







Related Discussions:- Matlab program - error-checking for integers, Assignment Help, Ask Question on Matlab program - error-checking for integers, Get Answer, Expert's Help, Matlab program - error-checking for integers Discussions

Write discussion on Matlab program - error-checking for integers
Your posts are moderated
Related Questions
Use of logical vector: Determine how many elements in the vector vec were greater than 5, the sum function can be used on the resulting vector isg: >> sum(isg) ans =

Complex numbers: A complex number is commonly written in the form z = a + bi here a is known as the real part of the number z, b be the imaginary part of z, and i is √-1

Creating Customized strings: There are many built-in functions which create customized strings, including blanks, char, and sprintf. We know that the char function can be u

Writing variables to a File: The save command is used to write variables to a file, or to append the variables to a MAT-file. By the default, save function writes to a MAT-fil

Function fopen - file function: The permission string in the call to the fopen function identifies that the file is opened for writing to it. Just as when reading from a file,

strvcat function - concatenation: The function strvcat will concatenate it vertically, that means that it will generate a column vector of the strings.   >> strvcat(fir

Example of Minimum and Maximum Value For matrices, the functions min and max operate column wise by the default: >> mat = randint(2,4,[1 20]) mat =    9   10   1

Nested IF-ELSE statements: The if-else statement is used to select between the two statements. In order to select from more than two statements, the if-else statements can als

Histogram: The histogram is a particular type of bar chart which shows the frequency of occurrence of the values within a vector. The Histograms use what are known as bins to

Illustration of a recursive function: illustration is of a recursive function which does not return anything, but simply prints. The below function prtwords receives a sentenc