-
Notifications
You must be signed in to change notification settings - Fork 0
Help_bouncing_ball_with_input
In this example, a ball bouncing on a moving platform is modeled in Simulink as a hybrid system with an input, where the input determines the height of the platform.
The files for this example are found in the package hybrid.examples.bouncing_ball_with_input :
- initialize.m
- ball_with_input.slx
- ball_with_input2.slx
- postprocess.m
The contents of this package are located in Examples\+hybrid\+examples\bouncing_ball_with_input (clicking this link changes your working directory).
The bouncing ball system on a moving platform is modeled as a hybrid system with the following data:
where
The following procedure is used to simulate this example using the model in the file Example_1_3.slx :
- Open hybrid.examples.bouncing_ball_with_input.ball_with_input.slx in Simulink.
- In Simulink, double click the block "Double Click to Initialize" to initialize variables (parameters, initial values, etc.).
- Start the simulation by clicking the "Run" button. Let the simulation finish.
- Double click the block "Double Click to Plot Solutions" to generate plots
The following diagram shows the Simulink model of the bouncing ball. When the Simulink model is open, the blocks can be viewed and modified by double clicking on them.
Looking inside the hybrid system block 'HS' shows that the functions
The Simulink blocks for the hybrid system in this example are included below. The Embedded MATLAB function blocks f, C, g, D are edited by double-clicking on the blocks in Simulink.
flow map f block
function xdot = f(x, u, parameters) % Flow map for Bouncing Ball with Input v = x(2); xdot = [v; parameters.gamma]; end
flow set C block
function inC = C(x, u) % Flow set indicator for Bouncing Ball with Input h = x(1); if (h >= u) % flow condition inC = 1; % report flow else inC = 0; % do not report flow end end
jump map g block
function xplus = g(x, u, parameters) % Jump map for Bouncing Ball with Input lambda = parameters.lambda; v = x(2); xplus = [u; -lambda*v]; end
jump set D block
function inD = D(x, u) % Jump set indicator function for Bouncing Ball with Input. h = x(1); v = x(2); if (h <= u) && (v <= 0) % jump condition inD = 1; % report jump else inD = 0; % do not report jump end end
Above, the functions
Let the input function be
The following plot depicts the hybrid arc for the height of the ball in hybrid time.
- Creating and Simulating Hybrid Systems
- Plotting Hybrid Arcs
- Creating and Simulating Composite Hybrid Subsystems
- Updating Code Designed for HyEQ Toolbox v2.04 to Use v3.0 Features.
- Example: Composite Hybrid System with Zero-order Hold Subsystem.
- Example: Composite Hybrid System with Switched Subsystem.