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

sprintf function: The sprintf function works precisely like the fprintf function, but rather than printing it generates a string. Here are some illustrations in which the outp

Differentiation: The derivative of a function y = f(x) can be written as follows or f  '(x) and is defined as the rate of change of the dependent variable y with respe

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

Fliplr function: The fliplr function "flips" the matrix from left to right (in another words the left-most column, the first column, become the last column and so on), and the

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

Indexed empty matrix: The Individual elements cannot be eliminated from matrices, as matrices always have the similar number of elements in every row. >> mat = [7 9 8; 4 6

How do I write a product series running from i to n of x''s using a for loop?

Strings as matrix: The matrix can be generated, that consists of strings in each row. Therefore, essentially it is created as a column vector of strings, but the final result

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