Modeling of track traffic light which works based on the Position of trains in Stateflow

4 ビュー (過去 30 日間)
I have 2 Trains which need to cross 2 Sections in the same track. To enter a section we need to know if it is already occupied by another train or not.
So I have as input the Position of both Trains PosTrain1 and PosTrain2 and the length of Sections (Section 1= (0:20) and Section 2 = (20:40))
I used the matlab function (ismember) to check if the train is in the Section or not.
BlockedSection=ismember(Train1,Section1) will return a logic value à if its 1 then the train exist in Section 1, and if not then it will return the value 0.
Does anyone have an idea how can I check both trains in both Sections in the same time?
Example for the detection of train 1 in Section1
function BusySection1 = FuncBusySection1(PosTrain1, Section1)
BusySection1 = ismember(PosTrain1,Section1);
end

採用された回答

Pavan Guntha
Pavan Guntha 2021 年 10 月 19 日
Hi,
You could write a function similar to 'FuncBusySection1' to know the position of both the trains at the same time. The function is as follows:
function [BusySection1, BusySection2] = FuncBusySection(PosTrain1, Section1, PosTrain2, Section2)
BusySection1 = ismember(PosTrain1,Section1);
BusySection2 = ismember(PosTrain2,Section2);
end
When this function is called the respective sections of both the trains is returned at the same time.
Hope this helps!
  1 件のコメント
SMTun
SMTun 2021 年 10 月 31 日
thank you a lot for this answer, yes i tryed it and it works well.

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by