Note: DiffPlug does not require MATLAB. The tracking feature is purely optional, and MATLAB is not required to view or diff Simulink models.
In the top right of every Simulink dialog, there is a button. While the button is engaged, MATLAB will mirror the selections you make in DiffPlug. This is especially useful for resolving differences which were detected in a diff. It even works for opening models in MATLAB from the history of a git repository.
- When you first press this button, you will have to establish a connection with a MATLAB instance.
- A confirmation message will print at the MATLAB console when the connection has been established.
- It might take a few seconds for MATLAB to load your model, but the tracking will be almost instantaneous once it is established. The tracking will continue until you toggle the tracking button to off.
- Now that you're connected to MATLAB, DiffPlug will reuse this connection until either DiffPlug or MATLAB are closed
- If you hover over the while tracking is active, you can open the Details of the MATLAB instance you are currently connected to.
- If you press the Click to flash MATLAB button, MATLAB's console and editor windows will flash green.
- This lets you know that the connection is working, and if you have several instances of MATLAB open it is helpful in quickly determining which instance you are controlling.
- Connections are persistent, so you don't have to connect every time.
- If you want to disconnect (so that you can connect to a different instance of MATLAB, for example), you can connect and disconnect as many times as you would like.
MATLAB can't open two models with the same name, even if they're in different folders. The consequence of this is that you can usually only track one side of a diff at a time. This is rarely a practical limitation, as there is usually only one model which is being actively modified.
There are some Simulink objects which cannot be highlighted using the MATLAB API. These objects include:
- Wires between blocks.
- Any element with a forward-slash (
/) in its name.
- Stateflow transitions which cross boxes.
Despite these limitations, the vast majority of elements are supported. If the object you click in DiffPlug doesn't light up in MATLAB right away, try clicking one of the elements next to it - that will usually be enough to help you find what you're looking for.