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

Complex numbers, Complex numbers: A complex number is commonly written...

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

Referring to and modifying the matrix elements, Referring to and Modifying ...

Referring to and Modifying the Matrix Elements: To refer to matrix elements, the row and then the column indices are given in parentheses (always the row index initially and t

Bar and barh functions - plot functions, bar and barh functions: For a...

bar and barh functions: For a matrix, the bar and barh functions will group altogether the values in each and every row. The illustration is as shown: rm = randint(2,4,[1

Indexed empty matrix, Indexed empty matrix: The Individual elements ca...

Indexed empty matrix: The Individual elements cannot be eliminated from matrices, as matrices always have the similar number of elements in every row. >> mat = [7 9 8; 4 6

Types of user-defined functions, Types of User-defined Functions: We k...

Types of User-defined Functions: We know how to write a user-defined function, stored in an M-file, which computes and returns one value. This is merely one type of the functi

Naive Gauss Reduction, Write a MATLAB function [d1, u1, l1, c1, r1] = Naive...

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

Nested if-else statements, Nested IF-ELSE statements: The if-else stat...

Nested IF-ELSE statements: The if-else statement is used to select between the two statements. In order to select from more than two statements, the if-else statements can als

Fliplr function - changing dimensions, Fliplr function: The fliplr fun...

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

Customizing plots, Customizing Plots : There are numerous ways to custo...

Customizing Plots : There are numerous ways to customize figures in the Figure Window. On clicking the Plot Tools icon will bring up the Property Editor & Plot Browser, with ma

Illustration of advanced file input and output, Illustration of Advanced fi...

Illustration of Advanced file input and output: For illustration, to refer to the third number in the first element of the cell array: >> subjdata{1}(3) ans =

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