MATLAB: How to populate the next term in an If/elseif code

iif else statementif statement

Here's my code:
N=[];
for i=1:length(timeStep);
if timeStep(i)>33;
N(i)=1;
elseif timeStep(i)<=33;
N(i)=0;
end
end
n=N';
n(1)=1;
If timeStep at i is greater than 33, I would like N of the NEXT term (i+1) to be populated with a 1. However, changing the code to N(i+1)=1 does not work.
What would make this work for me?
Thank you in advance.

Best Answer

Why should it not work to change it to N(i+1)=1?
I'm wondering what's the desired output for timeStep between 35 and 40?
In any case, you can very simply vectorize the code:
N=[1 timeStep>40];