필터 지우기
필터 지우기

Re-arrange matrix row elements so that a specific condition is fulfilled

조회 수: 2 (최근 30일)
Pseudoscientist
Pseudoscientist 2019년 5월 1일
댓글: Pseudoscientist 2019년 5월 2일
Say we have matrix
A =
1 2 3
1 3 5
1 2 4
2 3 7
The task is the re-arrange the row elements so that in no row 2 elements are in same order. For example rows 1 and 2 both have elements 1 and 3 so that three is after one. We can fliplr row 2 indices 1:2 and we get row 3 1 5. This has to be done for all rows. The problem in my algorithm is that it is slow and it ends up flipping some rows 3 times and some indices are again in the same order as in some rows.. Maybe this could be done with Answer Set Programming..
I have attached a matrix of 25 rows as test data
  댓글 수: 2
Walter Roberson
Walter Roberson 2019년 5월 1일
My suspicion is that in the general case you may need to backtrack. There is a temptation to start at the top and keep all the rows that work moving from top to bottom, but I have a suspicion that if you do that you might force contradiction on some of the rows that do not originally work. I suspect that you might need to deliberately dearrange some of the "good" entries.

댓글을 달려면 로그인하십시오.

답변 (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