How to find the index of the first repeating value.

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.

 Respuesta aceptada

Voss
Voss el 23 de Jun. de 2022
Editada: Voss el 23 de Jun. de 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])

Más respuestas (0)

Categorías

Más información sobre Signal Processing Toolbox en Centro de ayuda y File Exchange.

Productos

Versión

R2021b

Etiquetas

Preguntada:

el 23 de Jun. de 2022

Editada:

el 23 de Jun. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by