logical built-in functionsthere are built-in


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

Request for Solution File

Ask an Expert for Answer!!
Applications of MATLAB: logical built-in functionsthere are built-in
Reference No:- TGS0174920

Expected delivery within 24 Hours