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
The variance is generally defined in terms of the arithmetic mean as: At times, though, the denominator is defined as n instead of n - 1. The default definition used by t

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

Give the formula for a rational function that has a hole at x=7 & vertical asmptote at x=-3/2

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 =

Dimensions - matrix: The size and length functions in the MATLAB are used to find array dimensions. Length function returns the number of elements in the vector. The size func

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

Types of User-defined Functions: We know how to write a user-defined function, stored in an M-file, which computes and returns one value. This is merely one type of the functi

Built in recursive function in MATLAB: We have seen that the built-in function in MATLAB to compute factorials, termed as the factorial and we know how to implement the iterat

Built-in functions for Complex numbers:   We know that in MATLAB both i and j are built-in functions which return √-1 (therefore, they can be thought of as built-in constants).

Counting in a While Loop: Whenever it is not known ahead of the time how many values will be entered into the script, it is often essential to count the number of values which