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!

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Complex Logic 的更多信息

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by