Can the find function be used in a loop? I have not been able to get it to work. I have tried many ways but the find command doesn't seem to like "i" in the statement. Here are two different ways I have tried it:
%Inititalize variables (P1 is a vector generated earlier in the program)
P1_int(1)=1;
i=1;
c=(1:length(P1)-1);
intdurl(1)=intdur;
for i=2:21 P1_int(i)=find((ttot(c)<intdurl(i-1)) & (ttot(c+1)>intdurl(i-1))); % determines i when ttot is intdurl(i-1)
intdurl(i)=intdurl(i)+intdur;
end
I have also tried:
%Inititalize variables (P1 is a vector generated earlier in the program)
P1_int(1)=1;
i=1;
c=(1:length(P1)-1);
intdur=5;
for i=2:21 P1_int(i)=find((ttot(c)<intdur*(i-1) & (ttot(c+1)>intdur*(i-1))); % determines i when ttot is intdur*(i-1)
end
Thanks!
Best Answer