I have
A={[1,6,3,2],[3,5,6]};
all_el =[];
for i=1:length(A)
all_el(end)=A{i}
end
I want to have this result
all_ell=[1,2,3,5,6]

 採用された回答

Bhaskar R
Bhaskar R 2020 年 3 月 16 日

0 投票

all_el = unique([A{:}]);

2 件のコメント

NA
NA 2020 年 3 月 16 日
if A is
A={{[1,6,3,2]},{[3,5,6]}};
all_el = unique([A{:}]);
I have error
Bhaskar R
Bhaskar R 2020 年 3 月 16 日
int_res = cellfun(@(x)[x{:}], A, 'UniformOutput', false);
all_el = unique([int_res{:}]);

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

その他の回答 (1 件)

Sriram Tadavarty
Sriram Tadavarty 2020 年 3 月 16 日
編集済み: Sriram Tadavarty 2020 年 3 月 16 日

1 投票

Hi there,
It is not pretty clear as what you wanted to do.
To get the desired output, perform the following:
A={[1,6,3,2],[3,5,6]};
% With for loops
all_el =[];
for i=1:length(A)
all_el=[A{i} all_el];
end
all_el = unique(all_el);
% Without for loops
all_el = unique([all_el{:}])
Hope this helps.
Regards,
Sriram

カテゴリ

ヘルプ センター および File ExchangeInstall Products についてさらに検索

質問済み:

NA
2020 年 3 月 16 日

コメント済み:

2020 年 3 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by