I understand you are trying to use MATLAB's ‘int’ function to solve an integral with a variable upper bound directly in Simulink. Unfortunately, this approach might not work as expected because ‘int’ is designed for symbolic integration, which does not dynamically adapt to changing conditions during a Simulink simulation.
To address this, you can use a numerical approach within Simulink, which updates at each simulation step. A great way to achieve this is by using a MATLAB Function block with the ‘trapz’ function for numerical integration. Here's how you can do it:
- Add a MATLAB ‘Function Block’ in your Simulink model.
- Write the following code in the MATLAB ‘Function block’:
function y = variable_integral(u, t0, tf)
t = linspace(t0, tf, 100);
3. Connect the Inputs and Outputs appropriately as shown in figure below:
This method will dynamically compute the integral at each simulation step. Also, you may update the function code as per required integral.
For more detailed steps, you can refer to the following Simulink Documentation on MATLAB ‘Function Blocks’:
Hope it helps!