필터 지우기
필터 지우기

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

조회 수: 4 (최근 30일)
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

채택된 답변

the cyclist
the cyclist 2017년 12월 3일
sum(x(2:end)==1 & x(1:end-1)~=1)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by