필터 지우기
필터 지우기

Join some matrices without repeating arrays

조회 수: 1 (최근 30일)
Moe
Moe 2014년 11월 11일
편집: Andrei Bobrov 2014년 11월 11일
Suppose I have matrices r1, r2 and r3 as follows:
r1 = [50;10;90;30];
r2 = [60;50];
r3 = [30;20;100];
I need a join matrix r that it is included all arrays of other matrices. I used the following code:
r = [r1; r2; r3];
But I need a code that not repeated same arrays in r1, r2 and r3, like:
t = [50;10;90;30;60;20;100];

채택된 답변

Andrei Bobrov
Andrei Bobrov 2014년 11월 11일
편집: Andrei Bobrov 2014년 11월 11일
r1 = [50;10;90;30];
r2 = [60;50];
r3 = [30;20;100];
r = [r1; r2; r3];
[~,b] = unique(r,'first');
out = r(sort(b));
or
out = unique(r,'stable');

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by