how to get a parameter fo a block while simulation?
7 views (last 30 days)
Show older comments
Good day. I've got a question: how can I get the output parameter of (any) block while simulation? For instance, I have the followng model: two reservoirs exchanging the defined amount of liquid (because the pressure in reservoir1 is 1000Pa while the pressure in reservoir2 is 0Pa). And, let's say, I want the subsystem turn into red once the reservoir1 is empty.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/155012/image.png)
So I write the code for one of the callbacks for this subsystems. But which one to choose? LoadFcn? StartFcn? and what should I write inside? I thought sth like
RVolume = get_param('untitled/reservoir1/', 'volume'); while (RVolume > 0) set_param('untitled/reservoir1/','BackgroundColor', 'blue'); end set_param('untitled/reservoir1/','BackgroundColor', 'red');
but the reservoir block does not have such a parameter as 'volume', hence the error message shows up. Then I decided to know all the parameters of the reservoir block, so I typed
get_param('untitled/reservoir1/','ObjectParameters') in the main matlab window
that is the result: and I can not find the parameter
Name: [1x1 struct]
Tag: [1x1 struct]
Description: [1x1 struct]
Type: [1x1 struct]
Parent: [1x1 struct]
Handle: [1x1 struct]
HiliteAncestors: [1x1 struct]
RequirementInfo: [1x1 struct]
Ports: [1x1 struct]
Position: [1x1 struct]
Orientation: [1x1 struct]
PortRotationType: [1x1 struct]
ForegroundColor: [1x1 struct]
BackgroundColor: [1x1 struct]
DropShadow: [1x1 struct]
IOType: [1x1 struct]
NamePlacement: [1x1 struct]
ShowName: [1x1 struct]
Priority: [1x1 struct]
Commented: [1x1 struct]
AttributesFormatString: [1x1 struct]
InstantiateOnLoad: [1x1 struct]
PolySpaceEndComment: [1x1 struct]
PolySpaceStartComment: [1x1 struct]
AncestorBlock: [1x1 struct]
ReferenceBlock: [1x1 struct]
LibraryVersion: [1x1 struct]
UserDataPersistent: [1x1 struct]
UserData: [1x1 struct]
RTWdata: [1x1 struct]
HDLData: [1x1 struct]
Diagnostics: [1x1 struct]
DialogParameters: [1x1 struct]
IntrinsicDialogParameters: [1x1 struct]
CompiledSampleTime: [1x1 struct]
InputSignalNames: [1x1 struct]
OutputSignalNames: [1x1 struct]
ModelParamTableInfo: [1x1 struct]
StatePerturbationForJacobian: [1x1 struct]
SCDEnableBlockLinearizationSpecification: [1x1 struct]
SCDBlockLinearizationSpecification: [1x1 struct]
CopyFcn: [1x1 struct]
DeleteFcn: [1x1 struct]
UndoDeleteFcn: [1x1 struct]
LoadFcn: [1x1 struct]
ModelCloseFcn: [1x1 struct]
PreSaveFcn: [1x1 struct]
PostSaveFcn: [1x1 struct]
InitFcn: [1x1 struct]
StartFcn: [1x1 struct]
PauseFcn: [1x1 struct]
ContinueFcn: [1x1 struct]
StopFcn: [1x1 struct]
NameChangeFcn: [1x1 struct]
ClipboardFcn: [1x1 struct]
DestroyFcn: [1x1 struct]
PreCopyFcn: [1x1 struct]
OpenFcn: [1x1 struct]
CloseFcn: [1x1 struct]
PreDeleteFcn: [1x1 struct]
ParentCloseFcn: [1x1 struct]
MoveFcn: [1x1 struct]
BlockType: [1x1 struct]
BlockDescription: [1x1 struct]
LinkStatus: [1x1 struct]
StaticLinkStatus: [1x1 struct]
PortConnectivity: [1x1 struct]
PortHandles: [1x1 struct]
LineHandles: [1x1 struct]
CompiledPortWidths: [1x1 struct]
CompiledPortDimensions: [1x1 struct]
CompiledPortDataTypes: [1x1 struct]
CompiledPortComplexSignals: [1x1 struct]
CompiledPortFrameData: [1x1 struct]
DataTypeOverride_Compiled: [1x1 struct]
MinMaxOverflowLogging_Compiled: [1x1 struct]
Capabilities: [1x1 struct]
IOSignalStrings: [1x1 struct]
RuntimeObject: [1x1 struct]
ExtModeUploadOption: [1x1 struct]
ExtModeLoggingSupported: [1x1 struct]
ExtModeLoggingTrig: [1x1 struct]
FontName: [1x1 struct]
FontSize: [1x1 struct]
FontWeight: [1x1 struct]
FontAngle: [1x1 struct]
Selected: [1x1 struct]
MaskType: [1x1 struct]
MaskDescription: [1x1 struct]
MaskHelp: [1x1 struct]
MaskPromptString: [1x1 struct]
MaskStyleString: [1x1 struct]
MaskVariables: [1x1 struct]
MaskTunableValueString: [1x1 struct]
MaskCallbackString: [1x1 struct]
MaskEnableString: [1x1 struct]
MaskVisibilityString: [1x1 struct]
MaskToolTipString: [1x1 struct]
MaskVarAliasString: [1x1 struct]
MaskInitialization: [1x1 struct]
MaskSelfModifiable: [1x1 struct]
MaskDisplay: [1x1 struct]
MaskIconFrame: [1x1 struct]
MaskIconOpaque: [1x1 struct]
MaskIconRotate: [1x1 struct]
MaskPortRotate: [1x1 struct]
MaskIconUnits: [1x1 struct]
MaskValueString: [1x1 struct]
MaskRunInitForIconRedraw: [1x1 struct]
MaskTabNameString: [1x1 struct]
Mask: [1x1 struct]
MaskCallbacks: [1x1 struct]
MaskEnables: [1x1 struct]
MaskNames: [1x1 struct]
MaskPropertyNameString: [1x1 struct]
MaskPrompts: [1x1 struct]
MaskStyles: [1x1 struct]
MaskTunableValues: [1x1 struct]
MaskValues: [1x1 struct]
MaskToolTipsDisplay: [1x1 struct]
MaskVisibilities: [1x1 struct]
MaskVarAliases: [1x1 struct]
MaskWSVariables: [1x1 struct]
MaskTabNames: [1x1 struct]
MaskObject: [1x1 struct]
ComponentPath: [1x1 struct]
ComponentVariants: [1x1 struct]
ComponentVariantNames: [1x1 struct]
ClassName: [1x1 struct]
SchemaVersion: [1x1 struct]
press: [1x1 struct]
press_unit: [1x1 struct]
init_volume: [1x1 struct]
init_volume_unit: [1x1 struct]
ret_diam: [1x1 struct]
ret_diam_unit: [1x1 struct]
loss_coeff: [1x1 struct]
loss_coeff_unit: [1x1 struct]
fluid_volume_Log: [1x1 struct]
flow_rate_ret_Log: [1x1 struct]
flow_rate_tank_Log: [1x1 struct]
pr_loss_ret_Log: [1x1 struct]
power_loss_Log: [1x1 struct]
LocalVarNames: [1x1 struct]
LocalVarDescs: [1x1 struct]
LocalVarLogging: [1x1 struct]
In fact, localvarnames shows me 'volume' as one of the parameters. but I cannot call it like
get_param('valve/Reservoir1/','volume')
as it says there is no such a parameter named 'volume'
So please help
0 Comments
Answers (1)
See Also
Categories
Find more on Variable Initialization in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!