Info
Questa domanda è chiusa. Riaprila per modificarla o per rispondere.
For loop combo troubles
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
Walter Roberson
il 9 Ott 2015
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 Commenti
Questa domanda è chiusa.
Vedere anche
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!