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
Logical Vectors: The relational operators can also be used with the vectors and matrices. For illustration, let's say that there is a vector, and we want to compare each eleme

User-defined functions: Therefore, although many functions compute and return values, some do not. A few functions rather merely accomplish a task. Regardless of what type of

Illustration of Advanced file input and output: For illustration, to refer to the third number in the first element of the cell array: >> subjdata{1}(3) ans =

Program of built-in factorial function: Calling this function yields similar result as the built-in factorial function: >> fact(5) ans =   120 >> factorial(

Writing and Reading Spreadsheet Files: The MATLAB functions xlswrite & xlsread will write to and read from the spreadsheet files which have the extension .xls. For illustratio

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

Matrix of Plots: The other function which is very useful with any type of plot is subplot that creates a matrix of plots in the present Figure Window. The three arguments are

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

Refer the subset of a matrix: It is also possible to refer to the subset of a matrix. For illustration, this refers to the first & second rows, second & third columns: >> m

Customizing Plots : There are numerous ways to customize figures in the Figure Window. On clicking the Plot Tools icon will bring up the Property Editor & Plot Browser, with ma