MATLAB Answers

0

In Simulink, how to substitute the default configuration set, not adding a new one??

Asked by Dyson Freeman on 24 Jan 2014
Latest activity Edited by Jakub Krizan on 5 Dec 2016
Here I just list corresponding code sections:
hCs = getActiveConfigSet(gcs);
hCs_1 = hCs.copy;
attachConfigSet(gcs,hCs_1,true);
setActiveConfigSet(gcs,hCs_1.Name);
After running, There are two ConfigSets in the Model Explorer. Every time I run this code, the number of ConfigSet plus one. Although it will work correctly, but it potentially increase the model size. So I need to substitute not add a new ConfigSet, or a method that I can eliminate redundant Configs using command line.

  0 Comments

Sign in to comment.

2 Answers

Answer by ES
on 24 Jan 2014

% Simulink parameters which has to be checked
Configuration.Set = {
'SolverType'; ...
'Solver'; ...
'SolverMode'; ...
'AlgebraicLoopMsg'; ...
'BlockPriorityViolationMsg'; ...
'SingleTaskRateTransMsg'; ...
'CheckMatrixSingularityMsg'; ...
'UnderSpecifiedDataTypeMsg'; ...
'UnnecessaryDatatypeConvMsg'; ...
'VectorMatrixConversionMsg'; ...
'SignalLabelMismatchMsg'; ...
'UnconnectedInputMsg'; ...
'UnconnectedOutputMsg'; ...
'UnconnectedLineMsg'; ...
'ConsistencyChecking'; ...
'ArrayBoundsChecking'; ...
'InlineParams'; ...
'BlockReduction'; ...
'BooleanDataType'; ...
'ConditionallyExecuteInputs'; ...
'OptimizeBlockIOStorage'; ...
'ZeroCrossControl'; ...
'BrowserLookUnderMasks'; ...
'BrowserShowLibraryLinks'; ...
'ModelBrowserVisibility'; ...
'WideVectorLines'; ...
'ShowPortDataTypes'; ...
'ShowLineDimensions'; ...
'LibraryLinkDisplay'; ...
'SimBuildMode'; ...
'UpdateModelReferenceTargets'; ...
'UpdateHistory'; ...
'SFUnusedDataAndEventsDiag'; ...
'SFUnexpectedBacktrackingDiag'; ...
'SFInvalidInputDataAccessInChartInitDiag'; ...
'SFNoUnconditionalDefaultTransitionDiag'; ...
'SFTransitionOutsideNaturalParentDiag' ...
};
% Solver options
slConfig.SolverType = 'Fixed-step';
slConfig.SolverMode = 'SingleTasking';
% Diagnostics options
slConfig.Solver = 'FixedStepDiscrete';
slConfig.AlgebraicLoopMsg = 'error';
slConfig.BlockPriorityViolationMsg = 'error';
slConfig.SingleTaskRateTransMsg = 'warning';
slConfig.CheckMatrixSingularityMsg = 'warning';
slConfig.UnderSpecifiedDataTypeMsg = 'warning';
slConfig.UnnecessaryDatatypeConvMsg = 'warning';
slConfig.VectorMatrixConversionMsg = 'warning';
slConfig.SignalLabelMismatchMsg = 'warning';
slConfig.UnconnectedInputMsg = 'error';
slConfig.UnconnectedOutputMsg = 'error';
slConfig.UnconnectedLineMsg = 'error';
slConfig.ConsistencyChecking = 'none';
slConfig.ArrayBoundsChecking = 'none';
% Advanced settings
slConfig.InlineParams = 'off';
slConfig.BlockReduction = 'off';
slConfig.BooleanDataType = 'on';
slConfig.ConditionallyExecuteInputs = 'on';
slConfig.OptimizeBlockIOStorage = 'off';
slConfig.ZeroCrossControl = 'EnableAll';
% View settings %
slConfig.BrowserLookUnderMasks = 'on';
slConfig.BrowserShowLibraryLinks = 'on';
slConfig.ModelBrowserVisibility = 'on';
slConfig.WideVectorLines = 'on';
slConfig.ShowPortDataTypes = 'off';
slConfig.ShowLineDimensions = 'off';
slConfig.LibraryLinkDisplay = 'all';
% Additional settings %
slConfig.SimBuildMode = 'sf_nonincremental_build';
slConfig.UpdateModelReferenceTargets = 'Force';
slConfig.UpdateHistory = 'UpdateHistoryWhenSave';
% Stateflow settings %
slConfig.SFUnusedDataAndEventsDiag = 'error';
slConfig.SFUnexpectedBacktrackingDiag = 'error';
slConfig.SFInvalidInputDataAccessInChartInitDiag = 'error';
slConfig.SFNoUnconditionalDefaultTransitionDiag = 'error';
slConfig.SFTransitionOutsideNaturalParentDiag = 'warning';
% Write settings %
for i=1:length(Configuration.Set)
%converting cell string to string
strOptionName = char(Configuration.Set(i));
strSetting = slConfig.(strOptionName);
set_param(ModelName,strOptionName, strSetting);
end

  0 Comments

Sign in to comment.


Answer by Jakub Krizan on 5 Dec 2016
Edited by Jakub Krizan on 5 Dec 2016

To replace config set: 1. attach new one 2. set it active 3. detach old one
hCs = getActiveConfigSet(gcs);
hCs_1 = hCs.copy;
attachConfigSet(gcs,hCs_1,true);
setActiveConfigSet(gcs,hCs_1.Name);
detachConfigSet(gcs,hCs.Name);

  0 Comments

Sign in to comment.