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

How do I write a product series running from i to n of x''s using a for loop?

strvcat function - concatenation: The function strvcat will concatenate it vertically, that means that it will generate a column vector of the strings.   >> strvcat(fir

Animation: In this part we will observe a couple of ways to animate a plot. These are visuals, therefore the outcomes can't really be shown here; it is essential to type these

Polar Form: Any complex number z = a + bi can be thought of as a point (a,b) or vector in the complex plane in which the horizontal axis is the real part of z, and the vertica

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

sprintf function: The sprintf function works precisely like the fprintf function, but rather than printing it generates a string. Here are some illustrations in which the outp

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

Illustration of Variance For illustration, for the vector [4, 6, 1, 5], there are n = 4 values therefore n - 1 is 3. The mean of this data set is also 4. The variance will be

Fliplr function: The fliplr function "flips" the matrix from left to right (in another words the left-most column, the first column, become the last column and so on), and the