How can I linearize an already compiled model ?

19 ビュー (過去 30 日間)
Julien Prodigue
Julien Prodigue 2018 年 3 月 27 日
回答済み: Julien Prodigue 2018 年 3 月 30 日
I would like to improve the performance of my script which use linmod to linearize a simulink model in Matlab 2016b. The linmod function is used many times with different state/input vectors so I think compiling the model only once could improve performance.
The structure of my scipt would be :
feval(model,[],[],[],'lincompile');
for i = 1:numel(x)
out = linmod(model,x{i},u{i});
end
feval(model,[],[],[],'term');
But unfortunalty, it only works with the 'v5' linarization algorithm. With the default block by block algorithm, an error is raised when changing model parameters :
Error using dlinmod>local_push_context (line 293)
Cannot change the 'AnalyticLinearization' parameter while the model 'MyModel' is running
Error in dlinmod (line 181)
have = local_push_context(models, want);
Error in linmod (line 59)
[varargout{1:max(1,nargout)}] = dlinmod(model, Ts, varargin{:}, Args);
Is there any way to make linmod work with a compiled model ? Do you have any other idea to improve performance of many linearizations of the same model ?

採用された回答

Julien Prodigue
Julien Prodigue 2018 年 3 月 30 日
I have found a solution for this.
dlinmod sets some models parameters before computing the linearization and those parameters cannot be changed while the model is compiled : you juste have to set those parameters before compiling. Thus, the set_param wont raise an error if the parameter to set is already set to the same value.
set_param(model,'AnalyticLinearization','on');
set_param(model,'BufferReuse','off');
set_param(model,'SimulationMode','normal');
set_param(model,'RTWInlineParameters','on');
set_param(model,'InitInArrayFormatMsg','None');
feval(model,[],[],[],'lincompile');
for i = 1:numel(x)
out = linmod(model,x{i},u{i});
end
feval(model,[],[],[],'term');

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeTrimming and Linearization についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by