MATLAB: Does the input and output of the Continuous Integrator block not match in Simulink 7.2 (R2008b)

simulink

In the attached model Example.mdl, between 1.2 and 1.5 seconds, the input of the Continuous Integrator block is approximately 154 while the output is constant. I expect the output of the integrator to have a slope proportional to the input.

Best Answer

This situation can occur when a signal of sample time Fastest Discrete (sample time color red) is combined with a continuous signal using a Sum block. A discrete signal does not have minor time steps. When combined with a continuous signal through a Sum block, a discrete ramp signal becomes a stairs signal in continuous time. Each of these stair's steps has a duration corresponding to the discrete sample time. This stair pattern introduces a frequency component in the signal. This phenomenon can be observed using the Level-2 MATLAB file s-function attached with this solution.
In the attached model, the ode45 solver chooses by default a sample time which is the same as the discrete signal. This sample time is chosen by the Simulink solver because it respects the solver tolerances specified in the model configuration parameters.
Because of this sample time choice, the oscillations introduced by the discrete to continuous conversion are not seen in major time steps. Only one point per period is seen. In this specific case, the point displayed is the maximum value of a large oscillation.
To avoid this issue when a discrete signal is converted to continuous, it is recommended to reduce the default values specified in the Simulink solver configuration for “Max step size” to respect the Nyquist criteria (set it lower than half of the fastest discrete sample time) or the “Relative tolerance”.
For the attached model Example.mdl, a Max step size of 0.001 or a Relative tolerance of 1e-6 can be used to observe the complete behavior of the system.