Illustration of logical built-in functions, MATLAB in Mathematics

Assignment Help:

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

 


Related Discussions:- Illustration of logical built-in functions

Rational function, Give the formula for a rational function that has a hole...

Give the formula for a rational function that has a hole at x=7 & vertical asmptote at x=-3/2

User input in the while loop - program, User input in the while loop: ...

User input in the while loop: Here is an illustration of running this script: >> readonenum Enter a positive number: -5 Invalid! Enter a positive number: -2.2

Built-in functions for complex numbers, Built-in functions for Complex numb...

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

Function isreal - complex numbers, Function isreal - complex numbers: ...

Function isreal - complex numbers: The function isreal returns 1 for logical true when there is no imaginary part of the argument, or 0 for false when the argument does have a

Looping, How do I write a product series running from i to n of x''s using ...

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

Illustration of writing variables to a file, Illustration of Writing variab...

Illustration of Writing variables to a file: For illustration, in the below session in the Command Window, 3 variables are generated; these are then exhibited using who. Then,

Common form of the switch statement, Common form of the switch statement: ...

Common form of the switch statement: The common form of the switch statement is as shown below:   switch switch_expression   case caseexp1    action1   case cas

Functions to create special matrices, Functions to create special matrices:...

Functions to create special matrices: The MATLAB also has various functions which create special matrices. For illustration, the zeros function generates a matrix of all zeros

Morphological reconstruction, how can reconstruct just part of an image usi...

how can reconstruct just part of an image using imreconstruct?

Strcat function - concatenation, Strcat function - Concatenation : The ...

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

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd