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 Exchange에서 Install 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