Main Content

coder.mapping.defaults.set

Set value for property of model default mapping category

Description

example

coder.mapping.defaults.set(model,category,property,value,...) sets property values for a data or function default mapping category for a model. To determine valid category, property, and value combinations for a model, use calls to:

  • coder.mapping.defaults.dataCategories

  • coder.mapping.defaults.functionCategories

  • coder.mapping.defaults.allowedProperties

  • coder.mapping.defaults.allowedValues

Examples

collapse all

For model rtwdemo_configuredefaults, configure how the code generator handles model output data by default.

Determine the category name to specify for model output data by calling coder.mapping.defaults.dataCategories.

coder.mapping.defaults.dataCategories()

ans =

  1×9 cell array

  Columns 1 through 4

    {'Inports'}    {'Outports'}    {'ModelParameters'}    {'ModelParameterA...'}

  Columns 5 through 8

    {'ExternalParamet...'}    {'SharedLocalData...'}    {'GlobalDataStores'}    {'InternalData'}

  Column 9

    {'Constants'}

Specify Outports as the category name.

Identify properties that you can configure for category Outports by calling coder.mapping.defaults.allowedProperties.

coder.mapping.defaults.allowedProperties('rtwdemo_configdefaults', 'Outports')

ans =

  4×1 cell array

    {'StorageClass'  }
    {'HeaderFile'    }
    {'DefinitionFile'}
    {'Owner'         }

For this example, set values for properties StorageClass, HeaderFile, and DefinitionFile.

Look up the values that you can specify for properties StorageClass, HeaderFile, and DefinitionFile.

coder.mapping.defaults.allowedValues('rtwdemo_configdefaults', 'Outports', 'StorageClass')

ans =

  9×1 cell array

    {'Default'              }
    {'ExportedGlobal'       }
    {'ImportedExtern'       }
    {'ImportedExternPointer'}
    {'Volatile'             }
    {'ExportToFile'         }
    {'ImportFromFile'       }
    {'AutoScope'            }
    {'GetSet'               }

coder.mapping.defaults.allowedValues('rtwdemo_configdefaults', 'Outports', 'HeaderFile')

ans =

  0×1 empty cell array

coder.mapping.defaults.allowedValues('rtwdemo_configdefaults', 'Outports', 'DefinitionFile')

ans =

  0×1 empty cell array

Use a call to function coder.mapping.defaults.set to configure the default settings. For category Outports, set StorageClass to ExportToFile. Specify exSysOut.h and exSysOut.c for the header and definition files.

coder.mapping.defaults.set('rtwdemo_configdefaults', 'Outports',...
  'Storageclass', 'ExportToFile',...
  'HeaderFile', 'exSysOut.h',...
  'DefinitionFile', 'exSysOut.c')

For model rtwdemo_configuredefaults, configure the default location in memory for storing code generated for model data elements such as signals, states, and zero crossings.

Determine the category name to specify for model internal data by calling coder.mapping.defaults.dataCategories.

coder.mapping.defaults.dataCategories()

ans =

  1×9 cell array

  Columns 1 through 4

    {'Inports'}    {'Outports'}    {'ModelParameters'}    {'ModelParameterA...'}

  Columns 5 through 8

    {'ExternalParamet...'}    {'SharedLocalData...'}    {'GlobalDataStores'}    {'InternalData'}

  Column 9

    {'Constants'}

Specify InternalData as the category name.

Identify properties that you can configure for category InternalData by calling coder.mapping.defaults.allowedProperties.

coder.mapping.defaults.allowedProperties('rtwdemo_configdefaults', 'InternalData')

ans =

  2×1 cell array

    {'StorageClass' }
    {'MemorySection'}

To configure the memory location, set the value for property MemorySection.

Look up the values that you can specify for property MemorySection.

coder.mapping.defaults.allowedValues('rtwdemo_configdefaults', 'InternalData', 'MemorySection')

ans =

  5×1 cell array

    {'None'           }
    {'MemVolatile'    }  
    {'functionFastMem'}
    {'functionSlowMem'}
    {'internalDataMem'}

Use a call to function coder.mapping.defaults.set to configure the default setting. For category InternalData, set MemorySection to internalDataMem.

coder.mapping.defaults.set('rtwdemo_configdefaults', 'InternalData',...
  'MemorySection', 'internalDataMem')

Input Arguments

collapse all

Model file, specified as a character vector. The model must be loaded (for example, by using load_system) or open. You can omit the .slx file extension.

Example: 'myLoadedModel'

Data Types: char

Category name, specified as a character vector. To get valid data and function category names, call the functions coder.mappings.defaults.dataCategories and coder.mappings.defaults.functionCategories.

Example: 'ModelParameters'

Data Types: char

Property name, specified as a character vector. To get valid property names for a default mapping category, call the function coder.mappings.defaults.allowedProperties.

Example: 'StorageClass'

Data Types: char

Property value, specified as a character vector. To get a list of values that you can specify for a category and property combination, call the function coder.mappings.defaults.allowedValues.

Example: 'ExportToFile'

Introduced in R2018a