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

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

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 =

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

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

Writing and Reading Spreadsheet Files: The MATLAB functions xlswrite & xlsread will write to and read from the spreadsheet files which have the extension .xls. For illustratio

Write a MATLAB function [d1, u1, l1, c1, r1] = NaiveGaussArrow(d, u, l, c, r) that takes as input the 5 vectors de ned above representing A. This function performs Naive Gauss redu

Built-in functions for Complex numbers:   We know that in MATLAB both i and j are built-in functions which return √-1 (therefore, they can be thought of as built-in constants).

Example of Recursive functions: This definition is recursive as a factorial is defined in terms of the other factorial. There are two parts to any recursive definition: the co

Strcat function - Concatenation : The strcat function, though, will eliminate the trailing blanks from strings before concatenating. Note that in these illustrations, the trail