Callback Button

Execute MATLAB code based on user input

  • Library:
  • Simulink / Dashboard

Description

The Callback Button block executes MATLAB® code based on user input. The Callback Button block reacts to clicks and presses from the user. You can specify separate code to execute for each action. The Callback Button block repeats the code specified for the press action at a specified rate as long as you continue to press the button.

The Callback Button block registers a click when you release the left mouse button with the cursor on the Callback Button. The code for a press executes when you click the Callback Button and hold for the specified Press Delay.

Double-clicking the Callback Button block does not open its dialog box during simulation and when the block is selected. To edit the block's parameters, you can use the Property Inspector, or you can right-click the block and select Block Parameters from the context menu.

Parameters

expand all

Text that appears on the button.

Mouse action that causes the MATLAB code to execute.

  • Select ClickFcn to view and edit the code that executes when the Callback Button block is clicked.

  • Select PressFcn to view and edit the code that executes when the button is pressed.

MATLAB code that executes based on user input.

Dependency

The MATLAB code displayed depends on the Mouse Action parameter selection.

  • Select ClickFcn to view and edit the code that executes when the Callback Button block is clicked.

  • Select PressFcn to view and edit the code that executes when the button is pressed.

Amount of time required to cause the PressFcn code to execute.

Dependency

Press Delay (ms) is only visible when PressFcn is selected as the Mouse Action.

Time interval after which the PressFcn code executes again if the Callback Button block is still pressed.

Dependency

Repeat Interval (ms) is only visible when PressFcn is selected as the Mouse Action.

Block Characteristics

Data Types

Direct Feedthrough

no

Multidimensional Signals

no

Variable-Size Signals

no

Zero-Crossing Detection

no

Extended Capabilities

Introduced in R2017b