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
Histogram: The histogram is a particular type of bar chart which shows the frequency of occurrence of the values within a vector. The Histograms use what are known as bins to

Recursive Functions: The Recursion occurs whenever something is defined in terms of itself. In the programming, a recursive function is a function which calls itself. The Recu

Illustration of Logical vectors: Calling the function appears to return similar vector as simply vec > 5, and summing the result still works to determine how many elements wer

Use of string variables: The Characters involve letters of the alphabet, punctuation marks, digits, white space, and control characters. The Control characters are characters

Sorting The Sorting is a process of putting a list in order; either in descending (maximum to minimum), or ascending (minimum to maximum) order. For illustration, here is a li

Plot types: Besides plot and bar, there are another plot types like stem plots, histograms, stem plots, area plots and pie charts, and also other functions which customize the

Script a MATLAB program which meets the following speci cations: The program expects an input of a two-variable real-valued continuous function f : R^2--> R The program is to cal

Illustration of Writing to files: Here is the other illustration in which a matrix is written to a file. At First, an arbitrary 2 × 4 matrix is generated, and then it is writt

Program of built-in factorial function: Calling this function yields similar result as the built-in factorial function: >> fact(5) ans =   120 >> factorial(

Illustration of Empty vectors: The Empty vectors can also be used to delete elements from the arrays. For illustration, to remove the third element from array, an empty vector