フィルターのクリア

create a loop/ switch elements

2 ビュー (過去 30 日間)
Marco Carapellese
Marco Carapellese 2022 年 3 月 3 日
編集済み: KSSV 2022 年 3 月 4 日
hello everybody, I need to create a loop, for repeat the sum in the 'if'. And I need to reassign the same element at traci.trafficlights.setPhaseDuration like switch from the same element. Thanks
if i==t(v)+(greentime(1,v)
traci.trafficlights.setPhase('B1', 1)
traci.trafficlights.setPhaseDuration('B1', greentime(2,v))
end
end
if i==t(v)+(greentime(3,v)
traci.trafficlights.setPhase('B2', 1)
traci.trafficlights.setPhaseDuration('B2', greentime(4,v))
end
end
if i==t(v)+(greentime(1,v)+ (greentime(2,v)
traci.trafficlights.setPhase('B1', 0)
traci.trafficlights.setPhaseDuration('B1', greentime(1,v))
end
end
if i==t(v)+(greentime(3,v)+greentime(4,v)
traci.trafficlights.setPhase('B2', 0)
traci.trafficlights.setPhaseDuration('B2', greentime(3,v))
end
end
if i==t(v)+(greentime(1,v)+ (greentime(2,v)+(greentime(1,v)
traci.trafficlights.setPhase('B1', 1)
traci.trafficlights.setPhaseDuration('B1', greentime(2,v))
end
end
if i==t(v)+(greentime(3,v)+greentime(4,v)+(greentime(3,v)
traci.trafficlights.setPhase('B2', 1)
traci.trafficlights.setPhaseDuration('B2', greentime(4,v))
end
end
... and repeat this 'sum' until i reach a contition (for example T<90)
  2 件のコメント
Benjamin Thompson
Benjamin Thompson 2022 年 3 月 3 日
You can use the while keword to create loop that continues until T >= 90. To provide a better answer we need more information. I do not see any use of "sum" in your pseudocode. Can you try to code this up in MATLAB and then ask more specific questions and post your code?
Jan
Jan 2022 年 3 月 3 日
The code cannot run due to missing closing parentheses:
if i==t(v)+(greentime(1,v)
% ^ ^ ???

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by