Deleting unnecessary values in numerical array
1 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
采纳的回答
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')
i2 = find(x(:,2)==0, 1, 'first')
x1 = x(i1:i2, :)
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Multidimensional Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!