Problem 576. Return elements unique to either input
Given two numeric inputs a and b, return a row vector that contains the numbers found in only a or only b, but not both. For example, the inputs:
a=[1 2 3 4 5];
b=[2 3 4 5 6];
would return [1 6], as 2, 3, 4 and 5 are in both a and b, and can therefore be eliminated. Please sort the returned vector in order from lowest to highest.
You may assume that there is at least one value that meets these criteria in a or b, and there are no NaN or Inf values in either a or b.
Solution Stats
Problem Comments
-
3 Comments
Your description says the inputs will be vectors, but your test suite includes matrices.
+1
Apologies for the incorrect terminology. The description has been updated.
Solution Comments
Show commentsProblem Recent Solvers802
Suggested Problems
-
The Goldbach Conjecture, Part 2
2407 Solvers
-
Are all the three given point in the same line?
598 Solvers
-
Check if number exists in vector
13695 Solvers
-
Generate a vector like 1,2,2,3,3,3,4,4,4,4
13487 Solvers
-
Area of an equilateral triangle
6747 Solvers
More from this Author80
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!