Logical built-in functions, MATLAB in Statistics

Logical Built-In Functions:

There are built-in functions in the MATLAB which are useful in conjunction with vectors or matrices of all logical true or false values; two of these are the functions 'any' and 'all'. The function 'any' returns a logical true when any element in a vector is logically true, and false if not. The function 'all' returns a logical true only when all elements are logically true. Here are some illustrations. For the variable vec1, all the elements are logical true therefore both any and all return true.

>> vec1 = [1 3 1 1 2];

>> any(vec1)

ans =

1

>> all(vec1)

ans =

1

For vec2, various elements are logical true so 'any' returns the true but 'all' returns false.

>> vec2 = [1 1 0 1]

vec2 =

1  1  0  1

>> any(vec2)

ans =

1

>> all(vec2)

ans =

0

Posted Date: 10/19/2012 5:54:11 AM | Location : United States







Related Discussions:- Logical built-in functions, Assignment Help, Ask Question on Logical built-in functions, Get Answer, Expert's Help, Logical built-in functions Discussions

Write discussion on Logical built-in functions
Your posts are moderated
Related Questions
function sortrows - sorting strings: The function sortrows sorts each and every row as a block, or group, and it also will work on numbers. Here in this illustration the rows

Logical errors: The Logical errors are more complicated to locate, as they do not result in any error message. The logical error is a mistake in reasoning by the programmer, b

Editor/Debugger: The MATLAB has numerous useful functions for debugging, and debugging can also be completed through its editor, which is known as the Editor/Debugger. Typi

Variable packages: Variable packages are now the vector of structures, hence each and every element in the vector is a structure. To show one element in the vector, an index i

Example of Functions which return values: Calling this function prints the circumference, since there is no way to store the value, hence, it can be used in following computat

Representing Logical true and False: It has been stated that expressions which are theoretically true really have the integer value of 1, and expressions which are theoretical

Steps for input output functions - Lower level file: The steps involved are as shown below:  Open the file.  Read the file, write to the file, or append to the file.

Illustration of Mode When there is more than one value with similar (highest) frequency, then the smaller value is mode. In the case below, as 3 and 8 appear twice in the vecto

Help function: Function is computing the two values, there are two output arguments in the function header (i.e., area & circum), that are placed in the square brackets [ ]. A

Example of Mode When no value appears more often than any other, the smallest value in the vector will be the mode of the vector. >> shortx = [2 5 1 4]; >> mode(shortx