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

2 views (last 30 days)
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

Accepted Answer

Pavan Guntha
Pavan Guntha on 19 Oct 2021
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!

More Answers (0)

Categories

Find more on Complex Logic in Help Center and File Exchange

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!