This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Port Callbacks

Block input and output ports have a single callback parameter, ConnectionCallback. This parameter allows you to set callbacks on ports that are triggered every time the connectivity of these ports changes. Examples of connectivity changes include adding a connection from the port to a block, deleting a block connected to the port, and deleting, disconnecting, or connecting branches or lines to the port.

Use get_param to get the port handle of a port and set_param to set the callback on the port. The callback code must have one input argument that represents the port handle. The input argument is not included in the call to set_param.

For example, suppose the currently selected block has a single input port. The following code sets foo as the connection callback on the input port:

phs = get_param(gcb, 'PortHandles');
set_param(phs.Inport, 'ConnectionCallback', 'foo');

where, foo is defined as:

function foo(portHandle)

Related Topics

Was this topic helpful?