create vector with no repeated triplet sequences based on another vector

Hi,
I have a vector A=[1,2,3,4,5,6].
If we split this vector into triplets, with moving window of 1, we get these triplets: 123,234,345,456.
What I would like to do is create another vector B, using the exact same numbers that is in A. But I need to make sure that the triplet sequences in B are not present in A. So something like B=[6,2,5,4,3,1] because the triplets we get are: 625,254,543,431 which are not present in vector A.
Thanks!

回答 (1 件)

Thorsten
Thorsten 2016 年 8 月 16 日
Just reverse order:
B = fliplr(A);

5 件のコメント

Yue Zhang
Yue Zhang 2016 年 8 月 16 日
Ah sorry, vector A was not a good example of the real vector I have to work with. The real vector I have is the numbers 1:4, each repeated 30 times, which then gets shuffled.
Thorsten
Thorsten 2016 年 8 月 16 日
That's not possible, if I understood you correctly:
If you have 4 different numbers 1:4, you can generate 4*3*2=24 different triplets. If you have 120 numbers, you can generate 118 triplets. They cannot be all different.
Yue Zhang
Yue Zhang 2016 年 8 月 16 日
It doesn't matter if the triplets in vector A are the same or if the triplets in vector B are the same. The crucial thing is that the triplets in vector A and vector B are different. Does that make it possible?
Thorsten
Thorsten 2016 年 8 月 16 日
編集済み: Thorsten 2016 年 8 月 16 日
You're right, then it would be possible. But I have no solution ready of how to achieve it.
Yue Zhang
Yue Zhang 2016 年 8 月 16 日
thank you for trying!

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeMatrices and Arrays についてさらに検索

タグ

質問済み:

2016 年 8 月 16 日

コメント済み:

2016 年 8 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by