Main Content

validateModel

(To be removed) Validate and activate variant blocks in a model hierarchy

    validateModel will be removed in a future release. Use Simulink.VariantManager.activateModel instead.

    Description

    The validateModel function allows you to validate and activate a variant configuration on a model hierarchy. You can activate a named variant configuration defined for the model or the workspace configuration (temporary configuration in the base workspace or data dictionary used by the model).

    The process validates if the variant elements in the model such as variant blocks, variant controls, constraints, and the variant configuration are set up correctly. Activating a configuration:

    • Checks if applicable constraints are satisfied

    • Applies the variant control variable values defined in the configuration on the model

    • Pushes the variant control variable values to the base workspace or data dictionary used by the model, for use in simulation and code generation workflows

    [valid,errors] = validateModel(varconfigdata,modelName), where varconfigdata is a Simulink.VariantConfigurationData object, returns the result of validating and activating the workspace configuration on the model hierarchy. The variant control variables must be defined in the base workspace or data dictionary used by the model.

    [valid,errors] = validateModel(varconfigdata,modelName,configName) returns the result of validating and activating the specified named variant configuration on the model hierarchy.

    Note

    Activation of a variant configuration performed by this function differs from the Simulink® update diagram process. See Differences Between Variant Manager Activation and Update Diagram Process.

    example

    Examples

    collapse all

    Add the path to the model file.

    addpath(fullfile(matlabroot,'examples','simulink_variants','main'));

    Load the model.

    load_system('slexVariantManagement');

    Activate and validate the model slexVariantManagement using the configuration LinInterExpNoNoise.

    [valid, errors] = Simulink.VariantConfigurationData.validateModel...
      ('slexVariantManagement','LinInterExpNoNoise')

    Input Arguments

    collapse all

    Variant configuration data object associated with the model modelName, specified as a Simulink.VariantConfigurationData object.

    Name of the model, specified as character vector.

    Example: "slexVariantManagement"

    Data Types: char

    Name of the variant configuration to be validated and activated, specified as character vector.

    Example: "LinInterExpNoNoise"

    Data Types: char

    Output Arguments

    collapse all

    True or false result, returned as a 1 or 0 of data type logical.

    List of errors, returned as an N*1 structure where N is the number of models with errors. The structure has these fields:

    FieldTypeDescription
    Modelchar

    Name of the model

    Errorsstructure

    An M*1 structure where M is the number of errors in the model. The structure has these fields:

    • Message

    • MessageID

    Version History

    Introduced in R2013b

    expand all