MATLAB: How to stop for loop

for loops stop code

for j=rr-3
for i=1:rr-1
if X(i)<=t(j) && t(j)<=X(i+1)
N{1}(j,i)=1;
else
N{1}(j,i)=0;
end
end
end
I want when the code catches N{1}(j,i)=1, then for the rest of N{1}(j,i)=0..How can I do this. I tried another ifelse and for lop but didn't work. Do you have any idea?
The program trying to catch N{1}(j,i)=1 and it does it properly.I want it to stop when N{1}(j,i)=0.

Best Answer

help break