Logical scalar values - operators, MATLAB in Engineering

Logical scalar values:

The MATLAB also has or and and operators which work element wise for the matrices:

1084_Logical scalar values.png

These operators will compare any of the two vectors or matrices, as long as they are of similar size, element-by-element, and return a vector or matrix of similar size of logical 1's and 0's. The operators |  | and && are only used with scalars, not matrices. For illustration,

>> v1 = [3 0 5 1];

>> v2 = [0 0 2 0];

>> v1 & v2

ans =

0  0  1  0

>> v1 | v2

ans =

1  0  1  1

>> v1 && v2

??? Operands to the || and && operators should be convertible to the logical scalar values.

1713_Logical scalar values1.png

As with numerical operators, it is significant to know that the operator precedence rules. Table shows the rules for the operators which have been covered faraway, in the order of the precedence.

 

Posted Date: 10/19/2012 6:00:14 AM | Location : United States







Related Discussions:- Logical scalar values - operators, Assignment Help, Ask Question on Logical scalar values - operators, Get Answer, Expert's Help, Logical scalar values - operators Discussions

Write discussion on Logical scalar values - operators
Your posts are moderated
Related Questions
Illustration of anonymous functions: Dissimilar functions stored in the M-files, when no argument is passed to an anonymous function, the parentheses should still be in the fu

Matrix definitions: As we know the matrix can be thought of as a table of values in which there are both rows and columns. The most common form of a matrix A (that is sometime

Algorithm for appex subfunction: The algorithm for appex subfunction is as shown:  Receives x & n as the input arguments.  Initializes a variable for running sum of t

Function iscellstr - string function: The function iscellstr will return the logical true when a cell array is a cell array of all the strings, or logical false if not. >>

IS Functions in Matlab: There are many functions which are built into MATLAB which test whether or not something is true; these function names start with the word is. As these

Dot Product: The dot or inner product of two vectors a and b is written as a • b and is defined as  In another words, this is like matrix multiplication when multiplyi

Use polyval to evaluate the derivative at xder. This will be the % slope of the tangent line, "a" (general form of a line: y = ax + b). % 4. Calculate the intercept, b, of t

Illustration of Subfunctions: This is an illustration of running this program: >> rectarea Please enter the length: 6 Please enter the width: 3 For a rectan

Binary Search: The binary search supposes that the vector has been sorted first. The algorithm is just similar to the way it works whenever looking for a name in a phone direc

Structures: The Structures are data structures which group together values which are logically related in what are known as the fields of structure. The benefit of structures