Find min and max of consecutive values in an array and save these values in a nx2 matrix
2 ビュー (過去 30 日間)
古いコメントを表示
Antonios Morellos
2020 年 9 月 22 日
コメント済み: Antonios Morellos
2020 年 9 月 22 日
So I need to find the min and max values of consecutive values stored in a vector like the following:
v = [670; 671; 672; 680; 681; 682; 700; 701; 702; 703;...]
My end goal is to have the min and max values displayed like so:
'The problem occurs in segments: 670 - 672, 680 - 682, 700 - 703, ...'
I hope I am specific.
Any Ideas?
Thanks
0 件のコメント
採用された回答
Bruno Luong
2020 年 9 月 22 日
v = [670; 671; 672; 680; 681; 682; 700; 701; 702; 703]
idx = find([true; diff(v(:))~=1; true]);
minmaxseq = [v(idx(1:end-1)) v(idx(2:end)-1)]
その他の回答 (0 件)
参考
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!