Trim the model across the parameter set.op = findop(mdl,ops,params,fopt);Linearize the model across the parameter and operating point set.sysBatch = linearize(mdl,io,op,params);Calculate the elapsed time.timeElapsedBatch = cputime - t;Run Linear Analysis Commands in a Loop with fastRestartForLinearAnalysisThe fastRestartForLinearAnalysis command will configure the model to minimize
compilations even when compiling commands are run inside a loop. The model will be
compiled once with calls to operspec, findop, and linearize in a loop.Run the loop and record execution time with fastRestartForLinearAnalysis "on".t = cputime;Turn fastRestartForLinearAnalysis "on". Provide AnalysisPoints to minimize
compilations between calls to findop and linearize.fastRestartForLinearAnalysis(mdl,'on','AnalysisPoints',io);
ops = operspec(mdl);
for i = N:-1:1
kp = KP(i);
ki = KI(i);
% make sure the block initialization is called after the parameters
% are updated when the model is in a compiled state
Simulink.Block.eval(blk);
% trim the model
op = findop(mdl,ops,fopt);
[j,k] = ind2sub(sz,i);
% linearize the model
sysFastRestartLoop(:,:,j,k) = linearize(mdl,io,op);
endTurn fastRestartForLinearAnalysis "off". This will uncompile the model.fastRestartForLinearAnalysis(mdl,'off');Calculate the elapsed time.3 Batch Linearization