Is there a way to represent linked-list functionality in Simulink?
6 ビュー (過去 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 件のコメント
Jon
2020 年 10 月 2 日
This article may be of interest (uses stateflow not linked list but might give you some ideas) https://www.mathworks.com/help/stateflow/ug/modeling-an-elevator-system-using-atomic-subcharts.html
回答 (1 件)
Jayanti
2024 年 9 月 20 日
In order to use Stateflow to simulate linked list functionality you can create states and transitions that mimic the behavior of linked list operations.
- 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.
- 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.
- 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.
0 件のコメント
参考
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!