Main Content

Open code generation example models from the documentation or command line

The example models included in Simulink® Coder™ and Embedded Coder® show you how to generate code for different use cases and meet different code generation goals. Use openExample to open example models from the command line. For example, to open the CodeBuildModel model, enter:

openExample('CodeBuildModel')

Before R2022b, the code generation example models were named rtwdemo_<model> and were available on the MATLAB® path. From R2022b to R2023b, the example models were removed from the path and renamed according to these tables. To find models and open examples, you can use this list or use the functions modelfinder and openExample.

Models Renamed in R2022b

These models are available with Simulink Coder and were renamed in R2022b.

R2022a model nameR2022b and later model nameExample
rtwdemo_col_dlut3d_selplaneColumnDLUT3DSelectPlaneDirect Lookup Table Algorithm for Row-Major Array Layout
rtwdemo_col_dlut3d_selvectorColumnDLUT3DSelectVector
rtwdemo_row_dlut3d_selplaneRowDLUT3DSelectPlane
rtwdemo_row_dlut3d_selvectorRowDLUT3DSelectVector
rtwdemo_condinputConditionalInputUse Conditional Input Branch Execution
rtwdemo_deadpathElimDeadPathEliminationEliminate Dead Code Paths in Generated Code
rtwdemo_foreachreuseForEachReuseGenerate Reusable Code from For Each Subsystems
rtwdemo_row_interpalgRowInterpolationAlgorithmInterpolation Algorithm for Row-Major Array Layout
rtwdemo_row_lut2dRowLUT2D
rtwdemo_mdlreftopTopModelCodeFile Packaging for Models (Code and Data)
rtwdemo_mdlrefbotReferenceModelCode

These models are available with Embedded Coder and were renamed in R2022b.

R2022a model nameR2022b and later model nameExample
rtwdemo_concurrent_executionMulticoreConcurrentTaskingModel Multicore Concurrent Tasking Application
rtwdemo_cppclassCppClassRateBasedConfigure C++ Class Interface for Rate-Based Models
rtwdemo_cppclass_expfcnCppClassExportFunctionConfigure C++ Class Interface for Export-Function Models
rtwdemo_cppclass_workflowCppClassWorkflowKeyIgnitionGenerate C++ Code from Simulink Models
rtwdemo_explicitinvocation_atomicsubsysAtomicSubsystemGenerate Code for Atomic Subsystems
rtwdemo_multirate_multitaskingMultirateMultitaskingModel Single-Core, Rate-Monotonic Multitasking Application
rtwdemo_multirate_singletaskingMultirateSingleTaskingModel Single-Core, Single-Tasking Application
rtwdemo_sil_blockSILBlockTest Generated Code with SIL and PIL Simulations
rtwdemo_sil_modelblockSILModelBlock
rtwdemo_sil_counterSILCounter
rtwdemo_sil_topmodelSILTopModel
rtwdemo_udtUserDefinedDataTypesDefine Abstract Numeric Types and Rename Types

Models Renamed in R2023a

These models are available with Simulink Coder and were renamed in R2023a.

R2022b model nameR2023a and later model nameExample
rtwdemo_asap2ASAP2DemoCreate a Host-Based ASAM-ASAP2 Data Definition File for Data Measurement and Calibration
rtwdemo_asap2_mdlrefASAP2DemoModelRefCreate a Host-Based ASAM-ASAP2 Data Definition File for Data Measurement and Calibration
rtwdemo_col_interpselsubtableSubtableInterpolationColInterpolation with Subtable Selection Algorithm for Row-Major Array Layout
rtwdemo_float_mul_for_net_slope_correctionFloatMultiplicationNetSlopeFloating-Point Multiplication to Handle a Net Slope Correction
rtwdemo_forloopForLoopConstructOptimize Generated Code by Combining Multiple for Constructs
rtwdemo_inline_invariant_signalsInvariantSignalsInlineOptimize Generated Code Using Inline Invariant Signals
rtwdemo_row_interpselsubtableSubtableInterpolationRowInterpolation with Subtable Selection Algorithm for Row-Major Array Layout
rtwdemo_row_lutcol2row_workflowRowLUTColToRowColumn-Major Layout to Row-Major Layout Conversion of Models with Lookup Table Blocks
rtwdemo_row_lutcol2row_workflow_rowrowRowLUTColToRowPreconfiguredColumn-Major Layout to Row-Major Layout Conversion of Models with Lookup Table Blocks
rtwdemo_secondOrderSystemSecondOrderSystemGenerate C Code for a Model
rtwdemo_slexprfoldFoldBlockComputationsFold Expressions

These models are available with Embedded Coder and were renamed in R2023a.

R2022b model nameR2023a and later model nameExample
rtwdemo_accel_sendAccelerometerSendMessagesModel Message-Based Communication Integrated with POSIX Message Queues
rtwdemo_callerSimulinkFunctionCallerGenerate Code for Simulink Function and Function Caller
rtwdemo_differentsizereuseDifferentSizeReuseReuse Buffers of Different Sizes and Dimensions
rtwdemo_export_functionsSimulinkFunctionsTestHarnessGenerate Code for Simulink Function and Function Caller
rtwdemo_functionsSimulinkFunctionsGenerate Code for Simulink Function and Function Caller
rtwdemo_getset_matrixGetSetMatrixUse GetSet with Matrix Data
rtwdemo_getset_scalarGetSetScalarAccess Legacy Data Using Get and Set Functions
rtwdemo_getset_structGetSetStructUse GetSet with Structured Data
rtwdemo_getset_vectorGetSetVectorUse GetSet with Vector Data
rtwdemo_gps_sendGPSSendMessagesModel Message-Based Communication Integrated with POSIX Message Queues
rtwdemo_internal_initInternalZeroInitializationRemove Zero Initialization Code for Internal Data
rtwdemo_label_guided_reuseSignalLabelReuseOptimize Generated Code by Using Signal Labels to Guide Buffer Reuse
rtwdemo_logicalAsBooleanLogicalAsBooleanOptimize Generated Code Using Boolean Data for Logical Signals
rtwdemo_minmaxMinMaxOptimizationOptimize Generated Code Using Minimum and Maximum Values
rtwdemo_optimize_globalMinimizeGlobalDataAccessMinimize Global Data Access
rtwdemo_optimize_global_ebfUseGlobalsForTemporaryResultsUse Global to Hold Temporary Results
rtwdemo_optionalDisableResetFunc_botDisableResetFunctionBottomRemove Reset and Disable Functions from the Generated Code
rtwdemo_optionalDisableResetFunc_topDisableResetFunctionTopRemove Reset and Disable Functions from the Generated Code
rtwdemo_pack_booleanPackBooleanDataOptimize Generated Code by Packing Boolean Data into Bitfields
rtwdemo_parenthesesParenthesizationStyleControl Use of Parentheses
rtwdemo_pos_estimatePositionEstimateMessagesModel Message-Based Communication Integrated with POSIX Message Queues
rtwdemo_preservedimensionsPreserveArrayDimsPreserve Dimensions of Multidimensional Arrays in Generated Code
rtwdemo_preservedimensions_slbusPreserveBusDimsPreserve Dimensions of Bus Elements in Generated Code
rtwdemo_reusableReusableGenerate Reentrant Code from Top Models
rtwdemo_reusable_cscReusableStorageClassSpecify Buffer Reuse for Signals in a Path
rtwdemo_reuse_globalGlobalReuseReuse Global Block Outputs in the Generated Code
rtwdemo_rollRollAxisAutopilotGenerate C Code from Simulink Models
rtwdemo_roll_harnessRollAxisAutopilotHarnessGenerate C Code from Simulink Models
rtwdemo_rootlevel_zero_initializationRootZeroInitializationRemove Initialization Code from Root-Level Inports and Outports Set to Zero
rtwdemo_rsim_param_tuningRsimParamTuningTune Parameters Interactively During Rapid Simulation
rtwdemo_unicodeMixedLanguagesAndLocalesInternationalization and Code Generation

Models Renamed in R2023b

These models are available with Simulink Coder and were renamed in R2023b.

R2023a model nameR2023b and later model nameExample
rtwdemo_atomicSubsystemAtomicGenerate Subsystem Code as Separate Function and Files
rtwdemo_codebuildCodeBuildModelCompile Code in Another Development Environment
rtwdemo_codebuild_refCodeBuildRefModel
rtwdemo_commentsCustomCodeCommentsGet Code Description of Generated Code
rtwdemo_configrpinterfaceConfigurationRapidPrototypingInterfaceAccess Signal, State, and Parameter Data During Execution
rtwdemo_counterCounterModelRegister Custom Toolchain and Build Executable
rtwdemo_dynamicioDynamicIOShare Data Between Code Generated from Simulink, Stateflow, and MATLAB
rtwdemo_fixpt1FixedPointCodeGenerationOptimize Generated Code Using Fixed-Point Data with Simulink, Stateflow, and MATLAB
rtwdemo_irtsharedStartupResetShutdownSharedStartup, Reset, and Shutdown Function Interfaces
rtwdemo_memsetMemsetOptimizationOptimize Generated Code Using memset Function
rtwdemo_mrmtbbMultirateMultitaskingBareBoardAnalyze Generated Data Code Interface Report
rtwdemo_mrstbbMultirateSingletaskingBareBoardTime-Based Scheduling Example Models
rtwdemo_parabuild_a_1ParallelBuildA1Reduce Build Time for Referenced Models by Using Parallel Builds
rtwdemo_parabuild_b_1ParallelBuildB1
rtwdemo_parabuild_b_2ParallelBuildB2
rtwdemo_parabuild_b_3ParallelBuildB3
rtwdemo_paraminlineInlineBlockParametersInline Numeric Values of Block Parameters
rtwdemo_ratetransMultirateMultitaskingRateTransitionsSeparate Rate Transition Block Code and Data from Algorithm Code and Data
rtwdemo_sfcn_rlsSFunctionForCodeReuseS-Functions for Code Reuse
rtwdemo_sfcn_rls_libSFunctionForCodeReuseLibrary
rtwdemo_srbbSingleRateBareBoardSingle-Rate Modeling (Bare Board, No OS)
rtwdemo_ssreuseGeneratedCodeFunctionReuseFunction Reuse in Generated Code
rtwdemo_targetsettingsTargetSettingsConfigure Run-Time Environment Options
rtwdemo_throttlecntrlThrottleControlConfigure Model, Generate Code, and Simulate
rtwdemo_throttlecntrl_testharnessThrottleControlTestHarness
rtwdemo_throttlecntrl_datainterfaceThrottleControlDataInterfaceConfigure Data Interface
rtwdemo_throttlecntrl_extfunccallThrottleControlExtFuncCallCall External C Functions
rtwdemo_underspecified_datatypeUnderspecifiedDataTypeUse single Data Type as Default for Underspecified Types

These models are available with Embedded Coder and were renamed in R2023b.

R2023a model nameR2023b and later model nameExample
rtwdemo_compClientServerCommunicationGenerate Reentrant Code from Simulink Function Blocks
rtwdemo_comp_cppCppComponentGenerate Reentrant Code from Simulink Function Blocks
rtwdemo_configinterfaceConfigurationInterfaceCreate Data Interface Configuration Programmatically
rtwdemo_controlflow_optControlFlowOptimizationOptimize Generated Code by Consolidating Redundant If-Else Statements
rtwdemo_cppCppSFunctionExternalCodeIntegrate External C++ Code into a Model Using S-Functions
rtwdemo_cppclass_export_functionsCppClassFunctionsHarnessGenerate C++ Function and Class Code for Export-Function Model
rtwdemo_cppclass_functionsCppClassFunctionsGenerate C++ Function and Class Code for Export-Function Model
rtwdemo_crossrelease_counterCrossReleaseCounterGenerate Component Source Code for Export to External Code Base
rtwdemo_crossrelease_integrationCrossReleaseIntegration
rtwdemo_crossrelease_protected_modelCrossReleaseProtectedModelUse Protected Models from Previous Releases to Perform SIL Testing and Generate Code
rtwdemo_crossrelease_unprotected_counterCrossReleaseUnprotectedCounter
rtwdemo_cscpredefCustomStorageClassesCreate Storage Classes by Using the Custom Storage Class Designer
rtwdemo_dimension_variantsDimensionVariantsImplement Symbolic Dimensions for Array Sizes in Generated Code
rtwdemo_fileprocessCustomFileProcessCustom File Processing (CFP) Templates
rtwdemo_fixptdivFixedPointOperationsOptimize Generated Code for Fixed-Point Data Operations
rtwdemo_func_dintegDiscreteIntegratorFunctionGenerate Reentrant Code from Simulink Function Blocks
rtwdemo_func_dinteg_cppFuncDintegCPPGenerate Reentrant Code from Simulink Function Blocks
rtwdemo_libcodegen_libLibraryCodeGenerationLibraryLibrary-Based Code Generation for Reusable Library Subsystems
rtwdemo_libcodegen_mdlLibraryCodeGeneration
rtwdemo_localizable_cscLocalizableStorageClassGenerate Local Variables with Localizable Storage Class
rtwdemo_mrmtosMultirateMultitaskingOSTime-Based Scheduling Example Models
rtwdemo_namerulesNameRulesApply Custom Naming Conventions to Identifiers
rtwdemo_nzcheckDivisionExceptionsRemove Code That Guards Against Division Exceptions for Integers and Fixed-Point Data
rtwdemo_pmsmfocPMSMControllerField-Oriented Control of Permanent Magnet Synchronous Machine
rtwdemo_pmsmfoc_systemPMSMSystem
rtwdemo_preprocessorPreprocessorConditionalsUsingVariantModelGenerate Code for Model References Connected to Variant Blocks
rtwdemo_linlVariants_linl
rtwdemo_linrVariants_linr
rtwdemo_nlinlVariants_nlinl
rtwdemo_nlinrVariants_nlinr
rtwdemo_preprocessor_subsysPreprocessorConditionalsUsingVariantSubsystemCompile Code Conditionally for Variations of Component Represented Using Variant Block
rtwdemo_rtwecintroEmbeddedCoderIntroGenerate Code Using Embedded Coder
rtwdemo_sfcppCppStateflowExternalCodeInsert External C++ Code into Stateflow Charts for Code Generation
rtwdemo_shrlibSharedLibraryCodeInterface to a Development Computer Simulator by Using a Shared Library
rtwdemo_symbolsIdentifierFormattingControl Formatting of Identifiers
rtwdemo_vxworksOSIntegrationDeploy Generated Component Software to Application Target Platforms