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 996859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:56:38+00:00 2026-05-16T06:56:38+00:00

I have a cell array where each element consists of a vector of ids.

  • 0

I have a cell array where each element consists of a vector of ids. I like to compute the union of all elements in the cell array. This is my current solution, but I feel it can be vectorized or have a more elegant solution:

union_ids = union(encounter_ids{1},encounter_ids{2});
for i=3:1:numel(encounter_ids);
    union_ids = union(union_ids,encounter_ids{i});
end
  • 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-16T06:56:38+00:00Added an answer on May 16, 2026 at 6:56 am

    If the cell array elements are row vectors, you can do this:

    union_ids = unique( [encounter_ids{:}] );
    

    instead if they are column vectors, then use:

    union_ids = unique( vertcat(encounter_ids{:}) );
    

    If you are unsure, or they happen to be both (some are row vectors, some are columns), then you can force them to be all column vectors:

    encounter_ids = cellfun(@(c)c(:), encounter_ids, 'UniformOutput',false);
    union_ids = unique( vertcat(encounter_ids{:}) );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to apply a function to each element of a cell array --
I have a column vector I want to convert to a cell array such
I have a table with each cell containing a label and a text field.
I have a workbook with two sheets. I would like to format the cell
i want to have two data on each row on my tableview. Something like
So I have an array with objects which each have several attributes including an
I have created a table view that pulls its cells from an array. Each
I have a UITableView with about 20 cells, in each cell there are three
I have a UITableView whose datasource is a NSMutableArray . The array consists of
Is there a way to make a DataGridView have no cell selected? I notice

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.