How to find repeated values after decimal in array?

조회 수: 2 (최근 30일)
Brandon Oliver
Brandon Oliver 2022년 5월 20일
댓글: Voss 2022년 5월 20일
I am trying to analyze the following column of data in an array:
868.1
567.1
413.1
1159.7
52.1
99.7
126.7
111.1
167.2
1322.2
15.1
43.7
290.6
I want to find the number of times that a number after the decimal point repeats itself and also identify certain patterns of numbers after the decimal point. For example, the number of times x.1 and x.7 repeat themselves. The numbers before the decimal represent time in milliseconds that a certain behavior occured, and the number following the decimal is a behavior identifier so in my example, x.1 followed by x.7 represents a certain behavior pattern that I want to identify on a larger scale. Any help would be much appreciated!

채택된 답변

Voss
Voss 2022년 5월 20일
data = [ ...
868.1
567.1
413.1
1159.7
52.1
99.7
126.7
111.1
167.2
1322.2
15.1
43.7
290.6];
behavior_identifier = round(10*mod(data,1))
behavior_identifier = 13×1
1 1 1 7 1 7 7 1 2 2
numel(strfind(behavior_identifier.',[1 7])) % [1 7] appears 3 times
ans = 3
  댓글 수: 2
Brandon Oliver
Brandon Oliver 2022년 5월 20일
Wow this worked! Thank you so much.
Voss
Voss 2022년 5월 20일
You're welcome!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Types에 대해 자세히 알아보기

태그

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by