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
Nested Functions: We have seen that the loops can be nested, that means that one inside of the other, functions can be nested. The terminology for nested functions is that an

Illustrations of Sequential search: The two illustrations of calling such function is as shown below: >> values = [85 70 100 95 80 91]; >> key = 95; >> seqsearch

fscanf function - file function: The fscanf reads matrix variable mat columnwise from the file specified by fid. The 'format' involves conversion characters much similar to th

Example of Function stubs: The three functions have not so far been written, though, therefore the function stubs are put in place so that the script can be executed and teste

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

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

Illustration of Binary search: An illustration to search for the key of 91 in the vector is as shown below: The table below shows what will happen in each iteration of

Curve Fitting: The data is fundamentally either discrete or continuous. In most of the applications, data is sampled, for illustration, The temperature recorded every ho

The IF Statement: The if statement selects whether or not the other statement, or group of statements, is executed. The common form of the if statement is as shown below: i

Properties of the text box - graphics objects: By using get will show properties of the text box, the illustration is as shown below: >> get(thand)   BackgroundColor