这个例子展示了如何使用命令行来细化模型的数据类型。
打开fxpdemo_feedback
模型。
模型=“fxpdemo_feedback”;open_system(模型);
Controller子系统使用定点数据类型。
sud =“fxpdemo_feedback /控制器”;open_system (sud)
创建一个DataTypeWorkflow。转换器
对象的Controller子系统的数据类型fxpdemo_feedback
模型。
转换器= DataTypeWorkflow.Converter (sud);
模拟模型并将结果存储在运行标题中InitialRun
.
转换器。CurrentRunName =“InitialRun”;converter.simulateSystem ();
确定运行期间发生的任何溢出。
饱和度的= converter.saturationOverflows (“InitialRun”)
saturations = Result with properties: ResultName: 'fxpdemo_feedback/Controller/Up Cast' SpecifiedDataType: 'fixdt(1,16,14)' CompiledDataType: 'fixdt(1,16,14)' ProposedDataType: " Wraps: [] saturations: 23 WholeNumber: 0 SimMin: -2 SimMax: 1.9999 DerivedMin: [] DerivedMax: [] RunName: 'InitialRun' Comments:{'不能在此结果上指定输出数据类型。输出类型与输入类型相同。'} DesignMin: [] DesignMax: []
包装= converter.wrapOverflows (“InitialRun”)
包装= []
在仿真过程中,控制器子系统的Up Cast块出现饱和。没有换行溢出。细化模型的数据类型,以避免出现饱和。
使用快捷方式配置用于转换的模型。属性,找到系统可用的快捷方式ShortcutsForSelectedSystem
属性。
快捷键=转换器。ShortcutsForSelectedSystem
快捷方式= 6x1 cell array {'Range collection using double override'} {'Range collection with specified data types'} {'Range collection using single override'} {'Disable Range collection'} {'Remove override and Disable Range collection'} {'Range collection using scaled double override'}
为收集系统的理想范围,使用“使用双重覆盖的范围收集”
快捷方式,用双精度数据类型覆盖系统并启用检测。
converter.applySettingsFromShortcut(快捷键{1});
此快捷方式还更新转换器对象的当前运行名称属性。
baselineRun =转换器。CurrentRunName
baselineRun = '范围(Double) '
再次对模型进行模拟,以获取理想的距离信息。这些结果存储在运行中baselineRun
.
converter.simulateSystem ();
创建一个ProposalSettings
对象来控制数据类型建议设置并指定模型中信号的公差。
propSettings = DataTypeWorkflow.ProposalSettings;
指定输出信号的相对公差为20%PlantOutput
模型中的信号。
addTolerance (propSettings“fxpdemo_feedback /模拟植物”, 1“RelTol”2 e 1);
参数可以查看指定系统的所有公差showTolerances
方法。
showTolerances (propSettings)
路径Port_Index Tolerance_Type Tolerance_Value _________________________________ __________ ______________ _______________ {' fxpdemo_feedback /模拟植物'}1 0.2{“RelTol”}
中指定的建议设置为系统建议数据类型propSettings
,以及存储在baselineRun
运行。
转换器。proposeDataTypes (baselineRun propSettings)
应用为baselineRun
运行到模型。
converter.applyDataTypes (baselineRun)
验证使用新数据类型的模型的行为是否满足建议设置对象上指定的公差,propSettings
.的验证
方法删除数据类型覆盖,并使用更新的定点数据类型模拟模型。它返回一个DataTypeWorkflow。VerificationResult
对象。
结果=验证(转换器,baselineRun,“FixedRun”)
result = VerificationResult带有属性:ScenarioResults: [0x0 DataTypeWorkflow.]VerificationResult] RunName: 'FixedRun' BaselineRunName: 'Ranges(Double)' Status: 'Pass' MaxDifference: 0.0351
使用探索
的方法DataTypeWorkflow。VerificationResult
对象,启动仿真数据检查器并检查指定公差的信号。
探索(结果)