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 Center および File ExchangeLine Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by