Borrar filtros
Borrar filtros

Efficient way to count the number of times a value changes to a particular value in an array

4 visualizaciones (últimos 30 días)
What is the best way to do the following:
count=0;
for i=2:length(x)
if x(i)==1 && x(i-1)~=1
count=count+1;
end
end

Respuesta aceptada

the cyclist
the cyclist el 3 de Dic. de 2017
sum(x(2:end)==1 & x(1:end-1)~=1)

Más respuestas (0)

Categorías

Más información sobre Multidimensional Arrays en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by