For today's post, Brett and Jiro welcome guest blogger Greg Wolff.
Many of you are aware that you can connect a Single-Input Single-Output block in Simulink by dropping the block onto an existing signal line. Wouldn't it be nice to be able to have the same type of feature for sink blocks such as scopes so you can easily drop sinks onto existing Simulink signals?Mike Anthony has created the SinkAutoConnect function that when added to a Single-Input block's callback functions, will automatically connect the block to a signal line when you drop the block on an existing signal line.
When I am investigating the simulation results of Simulink models, it is convenient for me to quickly add scopes and outports to signals so I can log or inspect the results.
- Add a single-input block to a model or library.
- Right-click on the block to get the context menu and select Block Properties.
- Select the Callbacks tab in the Block Properties window.
- Select CopyFcn from the Callback functions list.
- Add the following text to the Content of callback function: "CopyFcn":
- Click OK
Now when you copy this block it can automate the connection to an existing signal line, if you drop the block on the existing signal line.To copy a block you can:
If you would like to leave any comments regarding this post, please click here.
コメントを残すには、ここ をクリックして MathWorks アカウントにサインインするか新しい MathWorks アカウントを作成します。