0
votes

I have a Simulink simulation that takes a control input U on an Inport, and simulates the state of the system based on that input. I want the simulation to use a variable time-step ode solver, but U is going to be defined as discrete time points (that aren't evenly spaced) that certainly aren't going to align with the times that are generated by (say) ode15s.

I want Simulink to take the U vector and a time vector, and use cubic spline interpolation to determine the value of U for times that do not align with the given U vector--similar to the 'Interpolate Data' option in the Inport preferences, except again my data is neither evenly spaced, nor do I want linear interpolation. How can I do this?

1

1 Answers

2
votes

A possible way to achieve this is the following. I am assuming the U vector is already known beforehand. This is implied from the fact the vector values are given at random sample moments which are not matching with the solver sample moments.

Take an '1-D interpolation table' block and connect a 'Clock' block as input. In the 1-D interpolation table you are able to specify 'Table data' in your case the values of the U vector. And you are able to specify the breakpoints that are in your case the time points. These can be variables from your workspace.

Then under the tabled 'Algorithm' you choose 'Cubic spline' for the interpolation method.

That should do the trick.