How to find the first entry of a sequence of values
조회 수: 4 (최근 30일)
이전 댓글 표시
I have a matrix of 2 columms by 128 rows. The first columm the numbers 4,5, and 6 appear in a random order. I need to find the first entry of each value in the columm 1. After, I need to find the corresponding value for each entry (4,5,6) position in the columm 2.
For example:
5 0
5 0.60
6 1.30
6 1.61
5 2.10
5 2.50
6 3.22
5 3.87
5 4.30
5 4.67
4 5.23
4 5.40
4 5.70
I need to find the bold numbers in the columm 1 and its respective values in the columm 2.
Thank you in advance,
댓글 수: 0
채택된 답변
Stephan
2019년 3월 21일
Hi,
try:
result = A([1; find(diff(A(:,1))~=0)+1],:)
gives the desired result:
result =
5.0000 0
6.0000 1.3000
5.0000 2.1000
6.0000 3.2200
5.0000 3.8700
4.0000 5.2300
Best regards
Stephan
댓글 수: 3
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!