Replace Duplicate Row Value in Matrix with other value of the matrix to create unique combination row wise

조회 수: 1 (최근 30일)
Hello everyone,
At this moment i am stuck with the following problem. I want to replace the duplicate values of each row with other value of the matrix. Each row will represnt a unqiue combination. For example,
My input matrix is
S = [3 2 3; 2 1 2; 1 2 1; 3 1 3;];
the output should be like:
S=[1 2 3; 2 1 3; 3 2 1; 3 1 2;];
Thanks in advance!

답변 (1개)

dpb
dpb 2022년 6월 3일
편집: dpb 2022년 6월 3일
There doesn't seem any reason to pick one possibility over another other than arbitrarily so one approach would be something like
P=perms(1:3);
S=randperm(size(P,1),size(S,1));

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by