Hello Benjamin,
Waypoint switching logic can be manually constructed by storing waypoints in a matrix or table and indexing through them. This can be implemented using either a MATLAB Function block or a Selector block in Simulink. Here's an example of both methods:
The flagGenerator function produces a Boolean signal that indicates when to switch to the next waypoint. The waypointSelector1 subsystem is an enabled subsystem that executes only when the flag is True; otherwise, it retains the previous output. Within this subsystem, a MATLAB function block contains the switching logic.
Alternatively, in the waypointSelector2 subsystem, a counter is created using Sum and Unit Delay blocks, and waypoint selection is performed using a Selector block. The scope output shows waypoint switching based on the flag.
For reference, the corresponding Simulink file, example_R2021a.slx, is attached. More information about the Selector block can be found in the documentation:
If waypoint navigation is to be performed using a lookahead point, check out the Waypoint Follower block.
I believe this will assist you!