Return unique items from two matrix

1 view (last 30 days)
Here are 2 matrix... (shape is 4 items in each entry and 5 entries). I want the unique entries. So for
>> f(:, 11:15)
ans =
24.1326 25.2125 25.2125 25.8147 25.8147
311.1230 418.3029 418.3029 329.6527 329.6527
2.0453 2.1123 2.1123 2.0111 2.0111
-3.2076 0.8975 -4.1030 -1.6351 -2.5608
>> g(:, 11:15)
ans =
25.2125 25.2125 25.8147 25.8147 26.1735
418.3029 418.3029 329.6527 329.6527 448.4572
2.1123 2.1123 2.0111 2.0111 2.0753
0.8975 -4.1030 -1.6351 -2.5608 -1.0299
The 2 unique items in the two matrix are ... (first entry in f)
24.1326
311.1230
2.0453
-3.2076
and (last entry in g)
26.1735
448.4572
2.0753
-1.0299
How can I find the unique items please?

Accepted Answer

Akira Agata
Akira Agata on 15 Oct 2018
How about this?
h = setxor(f',g','rows');
h = h';
The result is:
>> h
h =
24.1326 26.1735
311.1230 448.4572
2.0453 2.0753
-3.2076 -1.0299

More Answers (0)

Tags

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!