Effacer les filtres
Effacer les filtres

How to find the index of the first repeating value.

1 vue (au cours des 30 derniers jours)
Vahram Voskerchyan
Vahram Voskerchyan le 23 Juin 2022
Modifié(e) : Voss le 23 Juin 2022
I want to find the index of the first repeating value and plot a vertical line at that point, when the graph stabilizes.
a = [1,2,3,4,5,6,7,8,8,8,8,8,8,8,8,8,8,8,8]
b = linspace(0, 10, length(a));
plot(a,b)
%xline(b) exactly at the location where the values repeat in a.

Réponse acceptée

Voss
Voss le 23 Juin 2022
Modifié(e) : Voss le 23 Juin 2022
a = [1,2,3,4,5,6,7,8,8,8,8,8,8,8,8,8,8,8,8];
b = linspace(0, 10, length(a));
% plot(a,b)
plot(b,a)
idx = find(diff(a) == 0, 1)
idx = 8
xline(b(idx))
ylim([0 10])

Plus de réponses (0)

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Tags

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by