Intersect function and setdiff function, MATLAB in Engineering

Intersect function and setdiff function:

The intersect function rather than returns all the values which can be found in both of the input argument vectors.

>> intersect(v1,v2)

ans =

    3   5

The setdiff function receives two vectors as input arguments, and returns a vector having all the values which are contained in the first vector argument but not in the second. And hence, the order of the two input arguments is very important.

>> setdiff(v1,v2)

ans =

2 4 6

>> setdiff(v2,v1)

ans =

    1   7

Posted Date: 10/22/2012 7:32:17 AM | Location : United States







Related Discussions:- Intersect function and setdiff function, Assignment Help, Ask Question on Intersect function and setdiff function, Get Answer, Expert's Help, Intersect function and setdiff function Discussions

Write discussion on Intersect function and setdiff function
Your posts are moderated
Related Questions
Subfunctions: Though, it is possible to have more than one function in a given M-file. For illustration, if one function calls the other, the first function would be the prima

How can I use the weighted moving average formula in matlab to smooth a column data of 404 values?

Function fieldnames - structure functions: The function fieldnames will return the names of the fields which are contained in the structure variable. >> pack_fields = fiel

Appending variables to the Mat-File: Appending to the file adds to what has been saved in a file, and is accomplished by using the -append option. For illustration, supposing

Illustration of if - else statement: The one application of an if-else statement is to check for errors in the inputs to a script. For illustration, a former script prompted t

Example to change the line width from the default: For illustration, to change the line width from the default of 0.5 to 1.5: >> set(hl,'LineWidth',1.5) As long as the

Example of Plotting from a Function: For illustration, the function can be called as shown below:      >> y = [1:2:9].^3      y =     1  27  125  343  729

Example of modular program: In a modular program, there would be one main script which calls three separate functions to complete these tasks: A function to prompt an us

Cross Product: The cross or outer product a × b of two vectors a and b is defined only whenever both a and b are the vectors in three-dimensional space, that means that they b

Executing a program: Running the program would be completed by typing the name of the script; this would call the other functions: >> calcandprintarea Whenever prompt