How to extract values from an array?
이전 댓글 표시
Hello all,
I have an array with values that repeat , is it possible to determine the start and end points of a particular value in the array. For example
array = [10 10 10 30 30 30 30 30 4 4 4 4 4 30 30 30 30 30 30 2 2 2 2 2 30 30 30 30];
the goal is to extract those values in between the 30s.
How can i go about this? Thanks
댓글 수: 4
Rik
2022년 3월 9일
What would be the intended output? Perhaps this?
new_array=[4 2];
You can probably use most of the RunLength function Jan published on the file exchange.
Daniel Adeniyi
2022년 3월 9일
Rik
2022년 3월 9일
If you want to extract the numbers, do you mean you want [4 2], or [4 4 4 4 4 2 2 2 2 2];? (or something else)
That is also probably important information if David's answer doesn't work for you.
Daniel Adeniyi
2022년 3월 9일
채택된 답변
추가 답변 (1개)
카테고리
도움말 센터 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!