Changing Values in a column due to another value

조회 수: 1 (최근 30일)
Patrick Lonergan
Patrick Lonergan 2021년 5월 30일
답변: Dyuman Joshi 2021년 5월 30일
I have a collumn which contains 0s and 1s. The value 1 indicates that a failure occurred. I want to change the previous 6 rows prior to the failure to 1s also.
Does anyone have any idea about the best method to do this?

답변 (1개)

Dyuman Joshi
Dyuman Joshi 2021년 5월 30일
i = find(c==1,1,'first'); %c is the column vector
if i>6
c(i-6:i-1)=1;
else
c(1:i-1)=1;
end

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by