Split vector A into smaller vectors based on vector B

3 ビュー (過去 30 日間)
Francisco Anaya
Francisco Anaya 2019 年 3 月 4 日
コメント済み: KSSV 2019 年 3 月 4 日
I have two vectors of same lenght. Vector A contains angle data, and vector B contains gait phase (1=stand; 2=swing).
I want to split vector A into smallers vector for each individual gait cycle (1 stand + 1 swing).
My data is as follows:
Vector A Vector B
1.2 1
1.3 1
1.4 1
1.5 2
1.6 2
1.7 2
1.8 2
1.9 2
1.10 2
2.11 1
2.12 1
2.13 1
2.14 1
2.15 2
2.16 2
2.17 2
2.18 2
Then I want to split A into...
Vector C Vector D
1.2 2.11
1.3 2.12
1.4 2.13
1.5 2.14
1.6 2.15
1.7 2.16
1.8 2.17
1.9 2.18
1.10
Thank you!

採用された回答

KSSV
KSSV 2019 年 3 月 4 日
A = [1.2 1
1.3 1
1.4 1
1.5 2
1.6 2
1.7 2
1.8 2
1.9 2
1.10 2
2.11 1
2.12 1
2.13 1
2.14 1
2.15 2
2.16 2
2.17 2
2.18 2 ]
A1 = A(A(:,2)==1,1)
A2 = A(A(:,2)==2,1)
  2 件のコメント
Francisco Anaya
Francisco Anaya 2019 年 3 月 4 日
thank you. but can you write for when i have two vectors?
One is the vector data A, the other has the swing and stance phases vector B.
I want to cut vector A into full gait cycles of one 1 and one 2 in B.
hope this is clear
KSSV
KSSV 2019 年 3 月 4 日
A1 = A(B==1) ;
A2 = A(B==2) ;

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by