How to efficiently linearize a Simulink model at every time step?

5 views (last 30 days)
Dear colleagues,
I have a Simulink model of a non-linear system. I need a linearized representation (A,B,C,D matrices) of the system at every time step of the simulation. I did this:
model_name = 'lintest';
% prepare input
t = (0 : 0.1 : 10).';
u = sin(t);
% run simulation
sim(model_name);
% obtain linearized representation at every time step
lo = linoptions('SampleTime', 0);
tic;
[l, op] = linearize(model_name, tout, lo);
toc;
The "l" variable contains what I need. However, the call to "linearize" takes too long -- about 1.7 seconds for 51 time steps. The model I used for testing is very simple -- it is an Integrator block, a Product block, and a MATLAB Function block with y = u.^2 (see the attached .mdl file).
Is there a smarter way of doing this?
Best regards,
Mikhail

Answers (0)

Categories

Find more on General Applications in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!