Is there a way to count within the pattern, different points in a graph before repeating?

조회 수: 1 (최근 30일)
For these graphs shown (both are same), is there a way to find out how many unique points there are before repeating again? For example, this graph shows there are 4 unique points and after that it just repeats the pattern. So I would like to find a way to output the 4 wihtout me manually counting (or no. of unique points depending on the pattern).

채택된 답변

darova
darova 2021년 2월 19일
You can round data to integer and use unique
x0 = rand(10,1);
x1 = round(10*x0); % round data to 1 symbol after the dot
unique(x1)
  댓글 수: 2
Prayash Thapa
Prayash Thapa 2021년 2월 25일
The x-axis values increases but I would like the code to consider the y-axis values which repeats its unqiue values depending on the order. The y-axis is the part I want to consider if that makes sense. E.G. The graph shown has 4 different unique points before it repeats, lets say the unique points are 1,3,4,6 that is shown in the y-axis. Ignoring the x-axis, I would like to know how to display this order of 1,3,4,6.
darova
darova 2021년 2월 25일
unique can return indices too
[C,ia,ic] = unique(A) %also returns index vectors ia and ic using any of the previous syntaxes.
%If A is a vector, then C = A(ia) and A = C(ic).
see more help: LINK

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by