Hi,
I have a series of times in column 1. The times are 1.1, 1.1, 1.1, 1.2, 1.2, 1.2, 2.1, 2.1, 2.1 etc. I want to assign a unique number to each of these times. In order words, each time series should have its own number. Eg, all 1.1 should be assign the number 0, all 1.2 to the number 1 etc. A unique number to each series or repeating time. Any thoughts?
Thanks!

 채택된 답변

Andrei Bobrov
Andrei Bobrov 2020년 1월 18일

0 개 추천

a=[1.1, 1.1, 1.1, 1.2, 1.2, 1.2, 2.1, 2.1, 2.1]'
[i,g]=findgroups(a);
out = i - 1;

추가 답변 (1개)

Walter Roberson
Walter Roberson 2020년 1월 18일

0 개 추천

Use the third output of unique(). Or use findgroups()

카테고리

도움말 센터File Exchange에서 Workspace Variables and MAT Files에 대해 자세히 알아보기

제품

태그

질문:

2020년 1월 18일

댓글:

2020년 1월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by