Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7021347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:26:16+00:00 2026-05-27T23:26:16+00:00

Is there a nice function that will remove duplicate entries in a cell array?

  • 0

Is there a nice function that will remove duplicate entries in a cell array?

Some googling threw up the function ‘unique’, but it appears that only works if all the entries of the array are strings. Mine are 2×2 matrices.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T23:26:17+00:00Added an answer on May 27, 2026 at 11:26 pm

    I’ve used a combination of CELLFUN, CELL2MAT and UNIQUE. The idea is to convert each matrix to a vector, convert those cell array to a matrix and apply unique, The result you can convert back to cell array with NUM2CELL.

    x = {[1 2; 3 4], [1 2; 3 4], [5 6; 7 8], [1 2; 3 4], [5 6; 7 8]}';
    x1 = cellfun(@(y)y(:)', x, 'UniformOutput',0);
    x2 = cell2mat(x1);
    x3 = unique(x2,'rows');
    x4 = num2cell(x3,2);
    x5 = cellfun(@(y) reshape(y,2,2), x4, 'UniformOutput',0);
    

    Probably it can be done with less steps.

    It’s important to remember that this code will work only if all the cell array elements have the same size.

    You can check for this condition with

    assert(size(unique(cell2mat(cellfun(@size,x,'UniformOutput',0))),1) == 1,...
           'Cell elements have different size')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I got some binary files containing integers. Is there some nice Unix command, that
I'm wondering if there is something that will scan through your code and remove
In PHP 5.2 there was a nice security function added called input_filter, so instead
There are some nice free image to ASCII art conversion sites like this one:
There's a nice plugin for Frog CMS that lets you just type in yourpicture.120x120.jpg
I have a templated function fct that uses some complex data structure based on
I'm building some objects that will trigger custom events, and I'm using jQuery's bind
I have the following function that will convert a string into a numeric data
I've got some Python code that will automatically print a set of data in
Is there a nice way to split a collection into n parts with LINQ?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.