Borrar filtros
Borrar filtros

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

2 visualizaciones (últimos 30 días)
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);

Respuesta aceptada

Pavan Guntha
Pavan Guntha el 19 de Oct. de 2021
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);
When this function is called the respective sections of both the trains is returned at the same time.
Hope this helps!

Más respuestas (0)


Más información sobre Complex Logic en Help Center y File Exchange.





Community Treasure Hunt

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

Start Hunting!

Translated by