Use of logical vector, MATLAB in Mathematics

Use of logical vector:

Determine how many elements in the vector vec were greater than 5, the sum function can be used on the resulting vector isg:

>> sum(isg)

ans =

3

The logical vector isg can also be used to index into the vector. For illustration, when only the elements from the vector which are greater than 5 are preferred:

>> vec(isg)

ans =

9  6  11

As the values in the vector should be logical 1's and 0's, the below function which appears at first to accomplish the similar operation by using the programming method, really does not. The function receives 2 input arguments: the vector, and an integer with which to compare (therefore it is somewhat more common). It loops through each element in the input vector, and stores the result vector either a 1 or 0 based on whether vec(i) > n is true or false.

125_Use of logical vector.png

 

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







Related Discussions:- Use of logical vector, Assignment Help, Ask Question on Use of logical vector, Get Answer, Expert's Help, Use of logical vector Discussions

Write discussion on Use of logical vector
Your posts are moderated
Related Questions
Empty Vectors: An empty vector or in another words, a vector which stores no values, can be generated using the empty square brackets: >> evec = [] evec = [] >> lengt

how can reconstruct just part of an image using imreconstruct?

Complex numbers: A complex number is commonly written in the form z = a + bi here a is known as the real part of the number z, b be the imaginary part of z, and i is √-1

Illustrations of Variable number of output arguments: In the illustrations shown here, the user should actually know the type of the argument in order to establish how many va

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

Example of Symbolic Expression When there is more than one variable, the MATLAB selects which to solve for. In the illustration below, the equation ax 2 + bx = 0 is solved. Th

The variance is generally defined in terms of the arithmetic mean as: At times, though, the denominator is defined as n instead of n - 1. The default definition used by t

Using Functions with the Vectors and Matrices: As MATLAB is written to work with the vectors and matrices, the whole vector or matrix can be passed as an argument to the funct

Concatenation: The String concatenation means to join the strings altogether. Of course, as strings are merely vectors of the characters, the technique of concatenating vector

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