i want all the combinations for [abc]...like abc, ab, ac, bc, a, b, c. can anyone help..Plz...

I need all combinations....of k elements with n elements choosen..where n=k, k-1, n,.....1.

4 件のコメント

Omar Ahmed
Omar Ahmed 2021 年 3 月 13 日
|AB|
Omar Ahmed
Omar Ahmed 2021 年 3 月 13 日
I want to knowe that comand
Omar Ahmed
Omar Ahmed 2021 年 3 月 13 日
haw I can to use this comand |AB| in MATLAB
abs(A*B)
?? Or maybe
abs(AB)
abs(A.*B)
length(A)+length(B)

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

回答 (1 件)

Jos (10584)
Jos (10584) 2014 年 2 月 7 日
Take a look at my NCHOOSE function on the File Exchange as it does exactly what you're after.
S = nchoose('abc')
% S = {'a' 'b' 'ab' 'c' 'ac' 'bc' 'abc'}

2 件のコメント

i executed nchoose(s) but output is kind of weird...see this >> s=nchoose([1 2 3])
s =
[ 1]
[ 2]
[1x2 double]
[ 3]
[1x2 double]
[1x2 double]
[1x3 double]
What has gone wrong....Can't fix...any correction plz????
Jos (10584)
Jos (10584) 2014 年 2 月 8 日
Nothing is wrong … no fix or correction needed … Welcome to the world of cell arrays!
s is a cell array . Each element of s holds an single array. Since these arrays are not equally long they cannot be stored simply as rows in a rectangular matrix, unless you pad them (e.g. using PADCAT, also on the File Exchange).
To access such a single array in s you use curly brackets x = s{3} % -> x now holds [1 2]

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

カテゴリ

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

質問済み:

2014 年 2 月 7 日

コメント済み:

2021 年 3 月 14 日

Community Treasure Hunt

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

Start Hunting!

Translated by