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

1 view (last 30 days)
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).

Accepted Answer

darova
darova on 19 Feb 2021
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 Comments
Prayash Thapa
Prayash Thapa on 25 Feb 2021
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 on 25 Feb 2021
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

Sign in to comment.

More Answers (0)

Categories

Find more on Line Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!