Illustration of logical built-in functions, MATLAB in Mathematics

Illustration of logical built-in functions:

The function find returns the indices of a vector which meet certain criteria. For illustration, to find all the elements in a vector which are greater than 5:

>> vec = [5 3 6 7 2]

vec =

  5  3  6  7  2

>> find(vec > 5)

ans =

     3   4

 

The function is also equal and is useful in comparing the vectors. In MATLAB, using the equality operator with arrays will return 1 or 0 for every element; the all function could then be used on the resulting array to establish whether all elements were equal or not. The built-in function is equal and it also accomplishes this:

 

>> vec1 = [1 3 -4 2 99];

>> vec2 = [1 2 -4 3 99];

>> vec1 == vec2

ans =

1  0  1  0  1

>> all(vec1 == vec2)

ans =

0

>> isequal(vec1,vec2)

ans =

0

 

Posted Date: 10/19/2012 5:57:48 AM | Location : United States







Related Discussions:- Illustration of logical built-in functions, Assignment Help, Ask Question on Illustration of logical built-in functions, Get Answer, Expert's Help, Illustration of logical built-in functions Discussions

Write discussion on Illustration of logical built-in functions
Your posts are moderated
Related Questions
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

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

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

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

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

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

Error-Checking for Integers: As MATLAB uses the type double by default for all the values, to check to make confirm that the user has entered an integer, the program have to c

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

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

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