Deleting unnecessary values in numerical array

1 回表示 (過去 30 日間)
Nazar Adamchuk
Nazar Adamchuk 2021 年 10 月 15 日
回答済み: Chunru 2021 年 10 月 15 日
I have following ordered array (simplified):
1420 1
1410 1
1400 1
1390 0.9
1380 0.8
1370 0.7
...
1300 0
1290 0
1290 0
The first column is temperature, the second column is a physical quantity. I would need a solution how to cut the array so I have:
1400 1
1390 0.9
1380 0.8
1370 0.7
...
1300 0
So basically I need values between 1 and 0 meaning deleteing all unnecessary values before 1 and after 0. Can anybody help me?

採用された回答

Chunru
Chunru 2021 年 10 月 15 日
% Assume that your data in second column is sorted.
x = [
1420 1
1410 1
1400 1
1390 0.9
1380 0.8
1370 0.7
1300 0
1290 0
1290 0];
i1 = find(x(:,2)==1, 1, 'last')
i1 = 3
i2 = find(x(:,2)==0, 1, 'first')
i2 = 7
x1 = x(i1:i2, :)
x1 = 5×2
1.0e+03 * 1.4000 0.0010 1.3900 0.0009 1.3800 0.0008 1.3700 0.0007 1.3000 0

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by