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

Pie chart - plot functions: The MATLAB also has a function pie which will generate a pie chart. Calling the function with the form pie (vec) draws a pie chart, by using the pe

Find Minimum and Maximum for each row To find the maximum (or minimum) for each row, the dimension of 2 (that is how a MATLAB refers to rows) can be identified as the third arg

Give the formula for a rational function that has a hole at x=7 & vertical asmptote at x=-3/2

Refer the subset of a matrix: It is also possible to refer to the subset of a matrix. For illustration, this refers to the first & second rows, second & third columns: >> m

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

If I have a vector representing the packed storage form of a symmetric matrix, how do I perform a cholesky factorisation on that?

Plot Functions: Faraway, we have plotted to generate two-dimensional plots and bar to generate bar charts. We have seen how to clear the Figure Window by using clf, and how to

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

Nested IF-ELSE statements: The if-else statement is used to select between the two statements. In order to select from more than two statements, the if-else statements can als