Logical vectors, MATLAB in Mathematics

Logical Vectors:

The relational operators can also be used with the vectors and matrices. For illustration, let's say that there is a vector, and we want to compare each element in the vector to 5 to determine whether it is greater than 5 or not. The outcome would be a vector (with similar length as the original) with logical true or false values. Suppose a variable vec which is as shown here.

>> vec = [5 9 3 4 6 11];

In MATLAB, this can be automatically accomplished by simply using the relational operator >.

>> isg = vec > 5

isg =

0  1  0  0  1  1

Note that this generates a vector consisting of all the logical true or false values. Though this is a vector of ones and zeros, and numerical operations can be completed on the vector isg, its type is logical instead of double.

164_Logical Vectors.png

Posted Date: 10/19/2012 5:49:53 AM | Location : United States







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

Write discussion on Logical vectors
Your posts are moderated
Related Questions
fprintf function - File function: The fprintf function really returns the number of bytes which was written to the file, therefore if you do not want to see that number, suppr

Strings as Vectors: The Strings are considered as vectors of characters-or in another words, a vector in which each and every element is a single character-so numerous vector

Illustration of Advanced file input and output: For illustration, to refer to the third number in the first element of the cell array: >> subjdata{1}(3) ans =

5 p2+8p+15, 3 p2-3p-18, 12 p2-p-30

Example of Logical built-in functions: For equivalent to all the function, we should make sure that the entire elements in the vector are logically true. The one way of doing

Polar Form: Any complex number z = a + bi can be thought of as a point (a,b) or vector in the complex plane in which the horizontal axis is the real part of z, and the vertica

Three-Dimensional Plots: The MATLAB has many functions which will display three-dimensional plots. Most of these functions have similar name as corresponding two-dimensional p

Strings as matrix: The matrix can be generated, that consists of strings in each row. Therefore, essentially it is created as a column vector of strings, but the final result

Symbolic Expression The solve function solves an equation and returns the solution(s) as symbolic expressions. The answer can be converted to numbers by using any numeric funct

Creating Customized strings: There are many built-in functions which create customized strings, including blanks, char, and sprintf. We know that the char function can be u