MATLAB command for Union of an arbitrary collection of sets

Hi,
If there is an arbitrary collection of sets (denoted by a large U in mathematics), where each arbitrary set has some limit as well e.g, an index d=1 to D etc....
Can some one tell me which MATLAB command should be used for the above scenario?

6 件のコメント

Jan
Jan 2013 年 7 月 11 日
What exactly is "an arbitrary collection of sets"? Are you talking about the elements of a numerical vector or about a dataset vector?
Jos (10584)
Jos (10584) 2013 年 7 月 11 日
you're looking for a command UNION that takes more than two sets?
union(S1,S2,S3,S4,S4,S6, ...)
Syed
Syed 2013 年 7 月 11 日
Simon: i am not really sure
Syed
Syed 2013 年 7 月 11 日
i think its the elements of a numerical vecot since each set has different nu,ber of elements. e.g the first set has 1 element, the second set is a collection of 2 elements and so on...
Syed
Syed 2013 年 7 月 11 日
編集済み: Syed 2013 年 7 月 11 日
you can call the sets as coalitions in a coalitional game (in mathematics its called 'game theory')
Jan
Jan 2013 年 7 月 11 日
Please post some example data, preferrably by the Matlab commands used for their creation. E.g.:
x{1} = [1,3,45,6,2,1];
x{2} = [5,9,7,1];
or:
data.set(1).value = {23, 14:17}
data.set(2).value = {210, 15:31}
Or what ever. We cannot guess this detail. It does not matter, what these sets mean, e.g. if they are "coalitions" (what ever this might be), but only, how the data are represented and how the elements can be compared to determine uniqueness.

サインインしてコメントする。

回答 (1 件)

Jos (10584)
Jos (10584) 2013 年 7 月 11 日

0 投票

Here is a possible solution:
function U = munion (varargin)
% MUNION - union of multiple sets
% U = UNION(S1,S2,S3, ..., Sn) returns the union of sets S1 to Sn
U = varargin{1} ;
for k=2:nargin
U = union(U, varargin{k})
end

2 件のコメント

Syed
Syed 2013 年 7 月 11 日
what if i have limits as stated above in my question?
Jan
Jan 2013 年 7 月 11 日
@Syed: The limits are not well explained yet. It is hard to guess what "an index d=1 to D" explicitly means.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

製品

質問済み:

2013 年 7 月 11 日

Community Treasure Hunt

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

Start Hunting!

Translated by