金宝app®enables you to specify physical units as attributes on signals at the boundaries of model components. Such components can be:
Subsystems
Referenced Simulink models
Simulink-PS Converter(Simscape)andPS-Simulink Converter(Simscape)blocks that interface between Simulink and components developed in Simscape™ and its associatedphysical modeling下载188bet金宝搏
Stateflow®charts, state transition tables, or truth tables
MATLAB Functionblocks
Constantblocks
Data Store Memory,Data Store Read, andData Store Writeblocks
By specifying, controlling, and visualizing signal units, you can ensure the consistency of calculations across the various components of your model. For example, this added degree of consistency checking is useful if you are integrating many separately developed components into a large, overall system model.
In Simulink models, you specify units from aunit database。The unit database comprises units from the following unit systems:
SI
— International System of Units
SI (extended)
— International System of Units (extended)
English
— English System of Units
CGS
— Centimetre-gram-second System of Units
Based on the type of system you are modeling, you can use any combination of units from these supported unit systems. For more information about supported unit systems and the units they contain, seeAllowed Units。
You can assign units to signals through these blocks:
You can assign units to signals through these objects:
When you add a supported block to your model, theUnitparameter on the block is set toinherit
by default. This setting means that the block inherits the unit from a connecting signal that has an explicitly specified unit.
You can explicitly specify units for signals using theUnitparameter of a supported block. For this parameter, the dialog box provides matching suggestions to help you:
If you do not provide a correctly formed unit expression, you get an error. Correctly formed unit expressions are a combination of unit names or symbols with properly balanced parentheses and*
,/
, and^
字符。等特殊字符[
,]
,{
,}
,<
,>
,\
,"
,&
, and so forth are not supported.
By default, a block port has anempty(that is, unspecified) unit and theUnitparameter is set toinherit
。When you specify a unit for one port, Simulink checks the unit setting of any port connected to it. If a port has an empty unit, you can connect it to another port that has any supported unit. If a port unit parameter is set toinherit
, it inherits the unit from a connected port that has a specified unit.
To display the units on the Simulink lines in the model, on theDebugtab, clickInformation Overlays>Units。
When dealing with unitless, dimensionless, or no unit quantities, consider these guidelines:
Pure numbers with no units
Consider using1
, the SI standard dimensionless unit. Simulink checks the unit to make sure other dimensionless quantities are propagated in. You can add, multiply, and otherwise manipulate these types of numbers.
Unspecified units
Consider using an empty unit, where theUnitparameter is blank. When this parameter is blank, Simulink accepts any unit that propagates to the port without returning a warning.
Integer counting number unit
Consider usingcount
to denote an integer counting number unit. Use this unit for quantities that are difficult to describe, but that are considered unitless or dimensionless, such as thermally accessible states or PWM count. For more information, seecount
inAllowed Units。
Dimensionless physical quantities
Dimensionless physical quantities represent a specific physical quantity. Consider using the physical quantitiesvelocity_factor
,refractive_index
,relative_permeability
,strain
,Reynolds_number
, andlogical
。Some of these physical quantities,strain
andReynolds_number
, have corresponding units. To specify units for the other physical quantities, use a format such as1@physical quantity
, for example,1@refractive_index
。Simulink performs a physical quantity check at propagation. For example, if a model tries to add dimensional physical quantities, Simulink returns a warning.
Pure scaled numbers
Consider usingppm
,ppb
,ppt
。
When you model a physical system, it is possible to use the same unit expression for two or more signals that represent different physical quantities. For example, a unit expression ofN*m
can represent either torque or energy. To prevent mistaken connection of two ports with the same unit but representing different physical quantities, you can add a physical quantity to the unit expression. For example, for the same unit ofN*m
, you can specify different physical quantities ofN*m@torque
andN*m@energy
。Similar to units, the dialog box provides suggestions as you type the names of physical quantities.
Physical quantities help you to enforce an extra degree of unit consistency checking between connected ports. When you attempt to connect ports with different physical quantities, the model displays a warning.
By default,Simulink.ValueType
,Simulink.Signal
,Simulink.BusElement
, andSimulink.Parameter
objects have empty units. In the case of a:
Simulink.ValueType
object, the object does not attach a unit to the corresponding signals.
Simulink.Signal
object, the empty unit means that the corresponding signal can inherit a unit from an upstream or downstream port.
Simulink.BusElement
object, the empty unit means that the corresponding bus element also has an empty unit. You can connect the element to a port with any unit, but the element does not inherit a unit from the port.
Simulink.Parameter
object, the object does not attach a unit to the corresponding parameter value.
If you specify a unit in aSimulink.ValueType
,Simulink.Signal
, orSimulink.BusElement
object, Simulink applies the attribute to the corresponding signal line when:
TheSimulink.ValueType
object specifies the properties for a signal in the model.
TheSimulink.Signal
object resolves to a signal in the model.
TheSimulink.BusElement
object is associated with aSimulink.Bus
object and you use the corresponding bus element with aBus Creator,Bus Selector, orBus Assignmentblock that applies theSimulink.Bus
object.
For theSimulink.Parameter
object, Simulink does not apply any attribute. For all objects, if theUnitparameter has a value that is not formed correctly, you see an error. If the unit is formed correctly but is undefined, you see a warning when you compile the model. If the unit expression contains special characters such as[
,]
,{
,}
,<
,>
,\
,"
,&
, and so forth, Simulink replaces them with underscores (_
).
Notes on theUnit
andDocUnits
properties starting in R2016a:
TheDocUnits
property is nowUnit
forSimulink.Parameter
andSimulink.Signal
objects. If, in a previous release, you used theDocUnits
parameter of aSimulink.Parameter
orSimulink.Signal
object to contain text that does not now comply with units specifications, simulation returns a warning when the model simulates.
To suppress these warnings, set the configuration parameterUnits inconsistency messagestonone
。This setting suppresses all units inconsistency check warnings.
If you have a class that derives fromSimulink.Parameter
,Simulink.Signal
, orSimulink.BusElement
with a previously definedUnit
property, Simulink returns an error like the following:
Cannot define property 'Unit' in class 'classname' because the property has already been defined in the superclass 'superclass'.
If you use this property to represent the physical unit of the signal, delete theUnit
property from the derived class in the R2016a or later release. Existing scripts continue to work, unless you are assigning incorrectly formed unit expressions to theUnit
field. In this case, replace the use ofUnit
withDocUnits
to continue to be able to assign the unit expression.
Note
If you store existing data in a MAT- or。sldd
file, in a release prior to R2016a, copy the contents of theUnit
property to theDocUnits
first. Then, save the file in the earlier release before loading the model in R2016a or later release.
When modeling absolute temperature quantities, use units such asK
,degC
,degF
, anddegR
。When modeling temperaturedifferencequantities, use units such asdeltaK
,deltadegC
,deltadegF
, anddeltadegR
。If you connect a signal that has a temperature difference unit to a block that specifies anabsolutetemperature unit, Simulink detects the mismatch.
You specify the units for the inputs and outputs of aMATLAB Functionblock by specifying the units in theUnit (e.g., m, m/s^2, N*m)parameter in the Ports and Data Manager window. Double-click theMATLAB Functionblock to open the MATLAB Function Block Editor, clickEdit Datato open the Ports and Data Manager, then select the port of interest. When you type in theUnit (e.g., m, m/s^2, N*m)text box, the box suggests units that Simulink supports. By default, this property isinherit
,这意味着单位等于信号发送to the port. If you select theData must resolve to Simulink signal objectproperty for an output, the signal connected to the output port determines the port unit and the other properties except for theNameandScope。
MATLAB Functionblocks check if the Simulink signal unit matches the unit assigned to the corresponding input or output of the block. If the units do not match, Simulink displays a warning when you update the model. Otherwise, unit settings do not affectMATLAB Functionblock execution.
You can specify units for output data ofConstantblocks by using theUnitproperty in theSimulink.Parameter
object.
You can include units in signal data that you log or load.
You specify units for logging and loading using
objects. When you log usingSimulink.SimulationData.Unit
Dataset
orTimeseries
format, Simulink stores the unit information usingSimulink.SimulationData.Unit
objects. If you create MATLAB®timeseries data to load, you can specifySimulink.SimulationData.Unit
object for theUnits
property of thetimeseries
object.
For details, seeLog Signal Data That Uses UnitsandLoad Signal Data That Uses Units。
By default, you can specify units from any of thesupported unit systems。然而,在大型建模支持jects, to enforce consistency, you might want to restrict the unit systems that certain components of your model can use. To specify available unit systems for a model, in the configuration parameterAllowed unit systems, enterall
or a comma-separated list containing one or more ofSI
,SI (extended)
,CGS
, andEnglish
。Do not use quotation marks. If your model contains referenced models, you can use theAllowed unit systemsto restrict units in each of those referenced models. If your model contains subsystems, you can use theUnit System Configurationblock to restrict units in the subsystems. You can also optionally use aUnit System Configurationblock in a model. In this case, the settings in theUnit System Configurationblock override whatever you specify inAllowed unit systems。
To restrict unit systems in a model:
In theUnitparameter of theInport,Outport, orSignal Specificationblock, click the link.
If aUnit System Configurationblock exists in your model, this link opens the block dialog box. Otherwise, the link opens theAllowed unit systemsconfiguration parameter.
Specify one or more the desired unit systems,SI
,SI (extended)
,English
, orCGS
, in a comma-delimited list, orall
, without quotation marks.
In a parent-child relationship (for example, a top model with a referenced model or subsystem), you can specify different unit systems for each component. However, if a child propagates a unit into a parent that is not in the unit systems specified for the parent, you get a warning.
To check whether there are unit mismatches caused by restricted unit systems in your model hierarchy:
PressCtrl+Dand visually inspect the model for warning badges.
Use the Model Advisor checkIdentify disallowed unit systems。