Comparing between and within 3 columns of a matrix
조회 수: 2 (최근 30일)
이전 댓글 표시
Hello, I have a similar question to the one I asked before. I have 3 vectors to compare. Matrix below is a simplified form containing the 3 vectors A, B, C that I want to find the direction of. The values should increase from A to B to C in an ascending order the to the next A and continously like that. If the order is reversed, I want to recored it as negative. The negative continues until the direction is reversed again. Thank you for your response.
Sequence = [ 1, 2,3;4,5,6; 8, 9,7; 14,11,10; 15,13,12;16,20, 17; 18, 21, 19]
For example in the sequence above, I want to move across the columns from column 1 to column 2 to column 3 ( 1-2-3) continously till the end of the matrix in an ascending order. Any other direction is -ve i.e. 3 - 2, 1 - 3, 2 - 1, 1 -1, 2 to 2 or 3 to 3. E.g
1 to 2 is Positive. (I use +1)
2 to 3 is = +1
4 to 5 to 6 = +1
6 to 7 is = -1 (change in direction, ought to go back to next first column)
7 to 8 is = -1 (still continuing in the -ve direction )
8 to 9 = -1
9 to 10 = -1 (the direction is from second column to third column so no change of direction. same as before , )
10 to 11 = -(-1) = +1 ( there is a reversal of direction from column 3 to 2 instead of 1, direction is -ve of previous direction which gives positive).
11 to 12 = +1
12 to 13 = -1
13 to 14= -(-1) = +1
14 to 15 = -1 (ought to go to column 3 and not same column)
15 to 16 = -(-1) = +1
16 to 17 = -1
17 to18 is = -1 (same direction)
18 to 19 = -(-1) = +1
19 to20 is = -1
20 to 21 = -(-1) = +1
댓글 수: 4
Stephen23
2022년 12월 8일
"A different one was answered which I wanted to edit to this new question."
On this forum, completely altering and then removing questions is not considered as being polite.
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!