www.gusucode.com > ecoder 案例源码程序 matlab代码 > ecoder/ReusableCodeInterfaceExample.m

    %% Reusable Code Interface
% The |Reusable function| settomg of the model configuration parameter 
% *Code interface packaging* allows generated code to receive model data by
% function arguments. The generated code is reentrant. By default, |Reusable function| is not selected. Global data
% structures communicate model data to the generated code and access data
% with direct memory access. The generated code is not reentrant. 
%
% With Embedded Coder(R), you determine whether the generated code passes root-level 
% input and output as individual arguments, as structure references, or as part of the
% real-time model data structure. You can control
% whether the generated code allocates memory for model data statically or dynamically
% (using |malloc|).
open_system('rtwdemo_reusable');
%%
% To select the |Reusable function| Code interface packaging option:
%
% # From the Simulink Editor, select *Simulation > Model Configuration Parameters*
% # Select the *Code Generation > Interface* pane.
% # Select the |Reusable function| Code interface packaging check-box.
% # Configure the |Multi-instance code error diagnostic| option.
% # Configure the |Pass root-level I/O as| option (Embedded Coder only).
% # On the *All Parameters* tab, select *Use dynamic memory allocation for
% model initialization*.
%
bdclose('rtwdemo_reusable');