# Find 3 values equal and consecutive ​​in the row of a matrix.

1 ビュー (過去 30 日間)
Pedro Guevara 2019 年 5 月 16 日
Answered: Raghunandan V 2019 年 6 月 6 日
Goodnight. Disturbing them again with another concern. I have a matrix called "Cons" that in its last row is numbered (which is not necessarily ascending or has a consecutive order, like 1,2,3 ... etc). I want to look for groups of 3 elements (in that row) that are equal and consecutive, so that I can indicate the positions of these groups. It should be noted that the "Cons" matrix is ​​of variable size, and therefore the length of its last row depends on the size of the first. The variable "i" indicates the position of the last row. Below I leave an image to better illustrate the matter
Cons(BC,:)=[ ];
i=i-fila_Col_cero;
Thank you very much to all.

#### 2 件のコメント

Image Analyst 2019 年 5 月 17 日
Try diff(). Attach your data in a .mat file if you still need help.
Pedro Guevara 2019 年 5 月 17 日
Hi. thanks for your answer. Reading about the function "diff" I think this could not work, because as I said the row could take any value without necessarily following a consecutive (as if it follows in the image that showed: 1,1,1,2, 2,3,3,3,4,4). What I want to say is that the row can adopt any number as long as it complies with that order, the amount and repetition per group. Example: The row can be 11,11,11,85,85,6,6,6,7,7, and as you observe it complies with the quantity, order and repetition of the example that I mentioned earlier - 1,1,1, 2,2,3,3,3,4,4

サインイン to comment.

### 件の回答 (1)

Raghunandan V 2019 年 6 月 6 日
Hi Pedro,
Try to this lib by Jos
You can use this to solve your problem!
Regards,
Raghunandan V

#### 0 件のコメント

サインイン to comment.

サインイン してこの質問に回答します。

R2017b

Translated by