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
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

Persistent Variables: Generally, whenever a function stops executing, then the local variables from that function are cleared. That means that each and every time a function i

Reading from Files: There are many lower level functions which read from files. The function fscanf reads the formatted data into a matrix, by using conversion formats like %s

Operation on file: We concentrate first on the fgetl function that reads strings from the file one line at a time. The fgetl functions afford more control over how the data is

Program of Persistent variables: The program below elaborates this. The script calls a function func1 that initializes a variable count to 0, then increment it, and print the

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.

Generic code for Reading from Files: The generic code to complete this is as shown below:   fid = fopen('filename'); if fid == -1    disp('File open not suc

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

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

Vectorizing: In most of the cases in MATLAB, loops are not essential. As MATLAB is written specifically to work with the vectors and matrices, most operations can be completed