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
Standard Deviation The standard deviation is the square root of variance: The built-in function in a MATLAB for the standard deviation is known as std; the standard dev

Functions to create special matrices: The MATLAB also has various functions which create special matrices. For illustration, the zeros function generates a matrix of all zeros

Common form of the switch statement: The common form of the switch statement is as shown below:   switch switch_expression   case caseexp1    action1   case cas

Plot types: Besides plot and bar, there are another plot types like stem plots, histograms, stem plots, area plots and pie charts, and also other functions which customize the

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

Symbolic Expression The solve function solves an equation and returns the solution(s) as symbolic expressions. The answer can be converted to numbers by using any numeric funct

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

Plot Functions: Faraway, we have plotted to generate two-dimensional plots and bar to generate bar charts. We have seen how to clear the Figure Window by using clf, and how to

Illustration of Empty vectors: The Empty vectors can also be used to delete elements from the arrays. For illustration, to remove the third element from array, an empty vector

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,