How to find the first entry of a sequence of values

조회 수: 4 (최근 30일)
Gisele Gotardi
Gisele Gotardi 2019년 3월 21일
댓글: Gisele Gotardi 2019년 3월 21일
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,

채택된 답변

Stephan
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
Stephan
Stephan 2019년 3월 21일
Did you notice that you can accept and/or vote for useful answers?
Gisele Gotardi
Gisele Gotardi 2019년 3월 21일
I didn't. I have just voted.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Elementary Math에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by