Main Content

VersionResults

Results of upgrade operations

Description

AVersionResultsobject contains the results of each operation when upgrading the personal settings of a toolbox.

Creation

Create aReleaseCompatibilityResultsobject for a specific toolbox version number by using thematlab.settings.loadSettingsCompatibilityResults函数。然后,访问Resultsproperty to get theVersionResultsobject.

For example, this code gets theVersionResults对象的版本2of the toolboxmytoolbox.

myCompatibilityResults = matlab.settings.loadSettingsCompatibilityResults('mytoolbox','Version2'); myCompatibilityResults.Results
答= VersionResults with properties: VersionLabel: "Version2" VersionChanges: [1×2 matlab.settings.OperationResult]

Properties

expand all

Toolbox version of results, specified as a string scalar.

Example:"Version2"

Status for each upgrade operation, specified as an array of operation result objects.

Examples

collapse all

Create functions to create and then upgrade a toolbox factory tree and then test that the upgrade completes successfully.

The functioncreateMyToolboxFactoryTreecreates the factory settings tree for the toolboxmytoolbox.

functionmyToolboxFactoryTree = createMyToolboxFactoryTree() myToolboxFactoryTree = matlab.settings.FactoryGroup.createToolboxGroup('mytoolbox',...'Hidden'、假);toolboxFontGroup = addGroup (myToolboxFactoryTree,'font','Hidden',false) addSetting(toolboxFontGroup,'MyFontSize','FactoryValue',11,'Hidden',false,...'ValidationFcn',@matlab.settings.mustBeNumericScalar) addSetting(toolboxFontGroup,'MyFontColor','FactoryValue','Black',...'Hidden',false,'ValidationFcn',@matlab.settings.mustBeStringScalar);end

Create the functioncreateMyToolboxSettingsFileUpgraderswith an emptymatlab.settings.SettingsFileUpgraderobject.

functionupgraders = createMyToolboxSettingsFileUpgraders() upgraders = matlab.settings.SettingsFileUpgrader.empty;end

Create thesettingsInfo.jsonfile for the toolbox. Specifymytoolboxas the root settings group name,createMyToolboxFactoryTreeas the settings tree creation function, andcreateMyToolboxSettingsFileUpgradersas the settings tree upgrade function. PlacesettingsInfo.jsonin the toolboxresourcesfolder.

{"ToolboxGroupName":"mytoolbox","Hidden": false,"CreateTreeFcn":"createMyToolboxFactoryTree","CreateUpgradersFcn":"createMyToolboxSettingsFileUpgraders"}

Add the folder that contains the settings tree creation function and the toolbox resources folder to the MATLAB®path. Then, load the factory settings tree formytoolbox.

matlab.settings.reloadFactoryFile('mytoolbox');

Use thesettingsfunction to access the root of the settings tree and set the personal value for theMyFontSizesetting.

s = settings; s.mytoolbox.font.MyFontSize.PersonalValue = 15;

Change the settings names increateMyToolboxFactoryTreefromMyFontSizeandMyFontColortoFontSizeandFontColor.

functionmyToolboxFactoryTree = createMyToolboxFactoryTree() myToolboxFactoryTree = matlab.settings.FactoryGroup.createToolboxGroup('mytoolbox',...'Hidden'、假);toolboxFontGroup = addGroup (myToolboxFactoryTree,'font','Hidden',false) addSetting(toolboxFontGroup,'FontSize','FactoryValue',11,'Hidden',false,...'ValidationFcn',@matlab.settings.mustBeNumericScalar) addSetting(toolboxFontGroup,'FontColor','FactoryValue','Black',...'Hidden',false,'ValidationFcn',@matlab.settings.mustBeStringScalar);end

Record the rename of the two settings in thecreateMyToolboxSettingsFileUpgradersfunction as changes to the settings tree for version2ofmytoolbox.

functionupgraders = createMyToolboxSettingsFileUpgraders() upgraders = matlab.settings.SettingsFileUpgrader('Version2'); move(upgraders,'mytoolbox.font.MyFontSize','mytoolbox.font.FontSize'); move(upgraders,'mytoolbox.font.MyFontColor','mytoolbox.font.FontColor');end

Reload the factory settings tree formytoolbox.

matlab.settings.reloadFactoryFile('mytoolbox');

Use thesettingsfunction to access the root of the settings tree and verify that the personal value for theFontSizesetting was correctly moved from theMyFontSizesetting.

s = settings; s.mytoolbox.font.FontSize
答= Setting 'mytoolbox.font.FontSize' with properties: ActiveValue: 15 TemporaryValue:  PersonalValue: 15 FactoryValue: 11

Get the results of each upgrade operation for version2ofmytoolbox.

compatibilityResults = matlab.settings.loadSettingsCompatibilityResults('mytoolbox','Version2'); compatibilityResults.Results
答= VersionResults with properties: VersionLabel: "Version2" VersionChanges: [1×2 matlab.settings.OperationResult]

Version History

Introduced in R2019b