Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
For loop combo troubles
조회 수: 1 (최근 30일)
이전 댓글 표시
I have the following code: When i switches to 2 how can I make j pickup where it last left off (non-nan)? For example, when i is 1, the last non-nan value is when j = 5. So when i switches to 2, how can I make j start at 6 (instead of starting at the total beginning)?
for i = 1:4
for j = 1:14
try
shortIdx(j,i)=find(mid>=.20 & mid<=.30 & expiration==xDates(i) & option_type=='c' & sym==1 & quote_date==sellDate(j),1);
longIdx(j,i)=find(ask_eod<=.05 & expiration==xDates(i) & option_type=='c' & sym==1 & quote_date==sellDate(j),1);
catch
warning('Nothing there')
shortIdx(j,i)=nan;
longIdx(j,i)=nan;
end
end
end
댓글 수: 0
답변 (1개)
Walter Roberson
2015년 10월 9일
start_j = 0;
for i = 1:4
for j = start_j + 1:14
try
shortIdx(j,i)=find(mid>=.20 & mid<=.30 & expiration==xDates(i) & option_type=='c' & sym==1 & quote_date==sellDate(j),1);
longIdx(j,i)=find(ask_eod<=.05 & expiration==xDates(i) & option_type=='c' & sym==1 & quote_date==sellDate(j),1);
start_j = j;
catch
warning('Nothing there')
shortIdx(j,i)=nan;
longIdx(j,i)=nan;
end
end
end
댓글 수: 0
이 질문은 마감되었습니다.
참고 항목
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!