Running counters using S-functions
古いコメントを表示
Hello,
I am designing an autopilot waypoint tracking system. I have a list of waypoints. The autopilot is given the first as a reference waypoint and when the aircraft gets a distance D close to the waypoint, I want the reference to change to the next waypoint. I did this by having a flag based on whether the aircraft is D distance close to the waypoint or not (1 if it is and 0 if it is not). The flag increments a counter which keeps track of which waypoint is currently the reference.
I learned (the hard way) that variables passed to workspace during the simulation are not available until after the simulation and the only way to have a running counter would be through S-functions.
The question I have is: How can I (can I even?) build a simple S-function that increments a fixed counter based on a flag input and then outputs the value of the fixed counter (which will be used to determine the current waypoint)? I've been using the S-function builder but I'm not sure how to reference a static/global/base-workspace variable (I'm not too familiar with C either).
Any help would be tremendously appreciated.
~ IH
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Block and Blockset Authoring についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!