MATLAB Answers

in a loop like go back

2 views (last 30 days)
Lev Mihailov
Lev Mihailov on 19 Sep 2019
Edited: Matt J on 19 Sep 2019
Hello! Now I use this loop
for i=1:length(data)
if a(i)<=1
a(i)=a(i-1)
end
end
but I was faced with the calculation that the zones of zero values ​​and they give me the wrong result
a(i)=a(i-1) % find(a)
what’s the best way to write, not a (i-1), but write a (i up to the first value that meets the if condition)

  0 Comments

Sign in to comment.

Answers (1)

Matt J
Matt J on 19 Sep 2019
Edited: Matt J on 19 Sep 2019
first=find(a<=1, 1);
a(1:first)

  0 Comments

Sign in to comment.

Sign in to answer this question.

Products