Return elements unique to either input - MATLAB Cody - MATLAB Central

Problem 576. Return elements unique to either input

Difficulty:Rate

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

23.89% Correct | 76.11% Incorrect
Last Solution submitted on May 08, 2025

Problem Comments

Solution Comments

Show comments
LLMs with MATLAB updated to support the latest OpenAI Models
Large Languge model with MATLAB, a free add-on that lets you access...
2
3

Problem Recent Solvers778

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Go to top of page