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
Finding a sting - function strfind: The function strfind does necessarily similar thing, except that the order of the arguments does make dissimilarity. The common form is str

printrectarea function: function call: printrectarea(length, width) function header: function printrectarea(len, wid)   In the function call, there are two argume


Illustration of Variable scope: Running this function does not add any of variables to the workspace, as elaborated: >> clear >> who >> disp(mysum([5 9 1]))

Sorting Vectors of structures: Whenever working with vector of structures, it is very common to sort based on a particular field within the structures. For illustration, recal

Intersect function and setdiff function: The intersect function rather than returns all the values which can be found in both of the input argument vectors. >> intersect(v

Vectors of Structures: In numerous applications, involving database applications, information generally would be stored in the vector of structures, instead of in individual s

Example of Gauss-jordan: For a 2×2 system, this would results and for a 3 × 3 system, Note that the resulting diagonal form does not involve the right-most col

Illustration sorting vectors of structures: This function sorts the structures depend only on the price field. A more common function is shown next, that receives a string whi

num2str function: The num2str function, that converts real numbers, can be called in many ways. If only the real number is passed to the num2str function, it will generate a s