[KP,KI] = ndgrid(vp,vi);
N = numel(KP);
sz = size(KP);
Initialize the base workspace variables.
kp = KP(1);
ki = KI(1);
Run the loop and record execution time.
t = cputime;
ops = operspec(mdl);
for i = N:-1:1
kp = KP(i);
ki = KI(i);
% trim the model
op = findop(mdl,ops,fopt);
[j,k] = ind2sub(sz,i);
% linearize the model
sysLoop(:,:,j,k) = linearize(mdl,io,op);
end
Calculate the elapsed time.
timeElapsedLoop = cputime - t;
Run Linear Analysis Commands in Batch
Rather than loop over the parameters, findop and linearize can accept a batch
parameter variation structure directly to reduce the number of times the model is
compiled. The model will be compiled 3 times with calls to operspec, findop, and
linearize.
Run and record execution time.
t = cputime;
ops = operspec(mdl);
Create the batch parameter structure.
params(1).Name = 'kp';
params(1).Value = KP ;
params(2).Name = 'ki';
params(2).Value = KI ;
Improve Linear Analysis Performance