Split a vector into 2 vector before and after a value is found

1 回表示 (過去 30 日間)
Ana Tresca
Ana Tresca 2022 年 1 月 20 日
コメント済み: Ana Tresca 2022 年 1 月 20 日
Hello,
Lets say I have a vector with this values: a=[0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8]
I need to create 2 vectors, one that will include all values before 0.5 and another one the values above or equal with 0.5. How can i do this?

採用された回答

KSSV
KSSV 2022 年 1 月 20 日
編集済み: KSSV 2022 年 1 月 20 日
a=[0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8] ;
val = 0.5 ;
idx = find(a==val) ;
a1 = a(1:idx-1)
a1 = 1×4
0.1000 0.2000 0.3000 0.4000
a2 = a(idx:end)
a2 = 1×4
0.5000 0.6000 0.7000 0.8000

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by