Is there a way to represent linked-list functionality in Simulink?

23 次查看(过去 30 天)
Does anyone know a way t represent linked-list-type functionality in Simulink?
My problem is as follows:
I have an elevator dispatching system (currently written in C-code) that uses a linked-list mechanism to represent each stop that an elevator makes as it travels up and down the building. Each 'link' in the list represents a stop at a floor, and contains: floor number, previous stop, next stop, travel time to those stops, travel direction, and passenger info.
The linked list mechanism is used because it offers a convienient way to add new stops in the middle of the existing stops, and to calculate metrics for the whole trip or parts of the trip.
We are in the process of designing the next generation dispatcher, and I would like to figure out how to represent the above functionality in a simulink model.
At the moment, we are simply encapulating the existing c-code into a simulink block, but I would like to be able to create this from scratch using Simulink.
Any advice would be appreciated.
Don Kennedy

回答(1 个)

Jayanti
Jayanti 2024-9-20,13:53
In order to use Stateflow to simulate linked list functionality you can create states and transitions that mimic the behavior of linked list operations.
  1. To represent the nodes of the linked list you can use MATLAB structures. These structures can include various fields like floor number, previous stop, next stop, travel time to those stops, travel direction, and passenger info.
  2. Now, to perform various operations in this linked list you can use states. For example, if you want to add a new stop to the linked list you can have a state called add stop, this state will handle adding new stops to the linked list. Similarly, you can have various states like remove stop, traverse stop, etc.
  3. Further, to manipulate the list according to events use Stateflow actions where you can write actions like inserting a stop state into the list. Then use transition conditions to move between these states based on the events.

类别

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

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by