stop executing commands in a loop

1 回表示 (過去 30 日間)
joseph Frank
joseph Frank 2011 年 6 月 17 日
Hi,
if i have a loop and a condition is not met to continue the execution how can i tell the loop to skip the remaining commands for this iteration and continue the loop. example: for i=1:length(x) [y]=firm(x1,x2); if isempty(y) %% here : assume i=3 how can I tell the loop not to continue the remaining commands for i=3 and to continue the loop with i=4?
end end end end [S1,tic1]=sicfirms(SICY,SICx(i),Date02,Criteria1,Criteria2,GVKeyY); %%%%data related to the matching firm else S5(i,1:9)=0; S5(i,10)=1; %Type 1 error if here is no compustat criteria for the event firm end
  2 件のコメント
joseph Frank
joseph Frank 2011 年 6 月 17 日
sorry the last 4 lines were pasted by mistake
Ivan van der Kroon
Ivan van der Kroon 2011 年 6 月 17 日
so if y is empty it should not execute the remaining commands? then the if-statement works, right?

サインインしてコメントする。

採用された回答

Robert Cumming
Robert Cumming 2011 年 6 月 17 日
for i=1:length(x)
[y]=firm(x1,x2);
if isempty(y)
continue
end
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by