メインコンテンツ

isequal

Determine whether model configuration sets have same parameter values

Since R2026a

    Description

    tf = isequal(cs1,cs2) returns logical 1 (true) if configurations cs1 and cs2 have the same parameter values; otherwise, it returns 0 (false).

    [tf,parameters] = isequal(cs1,cs2) returns the logical result and a list of the parameters that have different values.

    example

    Examples

    collapse all

    This example shows how to compare the parameter values of two model configuration sets. For this example, compare the configuration of one model to the configuration of another model.

    Open the example models.

    model1 = "BusAssignment";
    model2 = "AlgebraicLoop";
    open_system(model1)
    open_system(model2)

    Get the active configuration set of each model.

    cs1 = getActiveConfigSet(model1);
    cs2 = getActiveConfigSet(model2);

    Determine whether the configurations are equal.

    [tf,parameters] = isequal(cs1,cs2);
    tf
    tf = logical
       0
    
    

    List the parameters that have different values in the configuration sets.

    parameters
    parameters = 1×10 cell
        {'ArithmeticOperatorsInVariantConditions'}    {'CovLogicBlockShortCircuit'}    {'CovMetricSettings'}    {'DLArmComputeVersion'}    {'MaxZcPerStep'}    {'RTWUseLocalCustomCode'}    {'ReturnWorkspaceOutputs'}    {'ReuseModelBlockBuffer'}    {'SimUseLocalCustomCode'}    {'StateflowObjectComments'}
    
    

    The example function CompareConfigSets reports the value of each differing parameter for each configuration set by calling get_param.

    type CompareConfigSets.m
    function result = CompareConfigSets(cs1,cs2)
    
    [tf,parameters] = isequal(cs1,cs2);
    
    if (tf)
        result = "The configuration sets are equal.";
        return
    else
    
        parameters = parameters';
        numDiff = length(parameters);
        
        cs1vals = cell(numDiff,1);
        cs2vals = cell(numDiff,1);
        
        for i = 1:numDiff
            param = string(parameters{i});
            try
                val = get_param(cs1,param);
            catch exception
                val = 'Parameter does not exist in this configset';
            end
            cs1vals{i} = val;
            try
                val = get_param(cs2,param);
            catch exception
                val = 'Parameter does not exist in this configset';
            end
            cs2vals{i} = val;
        end
        
        result = [parameters cs1vals cs2vals];
        
    end
    

    Use the example function to see the differing values of the parameters for the two configuration sets.

    CompareConfigSets(cs1,cs2)
    ans=10×3 cell array
        {'ArithmeticOperatorsInVariantConditions'}    {'warning'}    {'error'  }
        {'CovLogicBlockShortCircuit'             }    {'on'     }    {'off'    }
        {'CovMetricSettings'                     }    {'dswe'   }    {'dwe'    }
        {'DLArmComputeVersion'                   }    {'19.05'  }    {'20.02.1'}
        {'MaxZcPerStep'                          }    {[      1]}    {[      2]}
        {'RTWUseLocalCustomCode'                 }    {'off'    }    {'on'     }
        {'ReturnWorkspaceOutputs'                }    {'off'    }    {'on'     }
        {'ReuseModelBlockBuffer'                 }    {'on'     }    {'off'    }
        {'SimUseLocalCustomCode'                 }    {'off'    }    {'on'     }
        {'StateflowObjectComments'               }    {'on'     }    {'off'    }
    
    

    Input Arguments

    collapse all

    Configuration sets to be compared, specified as Simulink.ConfigSet objects.

    Output Arguments

    collapse all

    True or false result, returned as 1 (true) or 0 (false).

    Parameters that have different values in the configuration sets, returned as a cell array of character vectors. The list includes parameters that exist in only one of the configuration sets.

    Version History

    Introduced in R2026a