Simulink Control Design™ - MathWorks

(Tuis.) #1

timeElapsedFastRestartLoop = cputime - t;


Run Linear Analysis Commands in Batch with fastRestartForLinearAnalysis


Performance can be further improved by turning fastRestartForLinearAnalysis
"on" and executing the batch linearize and findop commands. The model will be
compiled once with calls to operspec, findop, and linearize.


Run and record execution time with fast restart for linear analysis on.


t = cputime;


Turn fastRestartForLinearAnalysis "on". Provide AnalysisPoints to minimize
compilations between the calls to findop and linearize.


fastRestartForLinearAnalysis(mdl,'on','AnalysisPoints',io);
ops = operspec(mdl);


Create the batch parameter structure.


params(1).Name = 'kp';
params(1).Value = KP ;
params(2).Name = 'ki';
params(2).Value = KI ;


Trim the model across the parameter set.


op = findop(mdl,ops,params,fopt);


Linearize the model across the parameter and operating point set.


sysFastRestartBatch = linearize(mdl,io,op,params);


Turn fastRestartForLinearAnalysis "off". This will uncompile the model.


fastRestartForLinearAnalysis(mdl,'off');


Calculate the elapsed time.


timeElapsedFastRestartBatch = cputime - t;


Comparing the Results


Compare the linearization results of the 4 methods. The bode plot below shows each
method returns the same results.


Improve Linear Analysis Performance
Free download pdf