You can add blocks to a signal, remove blocks from models, comment out and comment through blocks, and redraw connections. Suppose you want to add a bias to the input to both branches of your model and export the results to the MATLAB® workspace instead of a Scope block. Suppose you also want to add more blocks and another output to the subsystem.
Add a Bias block to the model and set the Bias
Drag the block onto the signal line after the Sine Wave block but before the branch. If you need to make room for the block, drag the Sine Wave block to the left or move the end of the branch by dragging it to the right.
When you drag the block onto the signal line, the block connects to the signal line at both ends. Release the block when you are satisfied with the position.
Remove the top Scope block. If you want to disconnect it from the model, but do not want to delete it, press and hold Shift and drag the block. Cut or delete it by pressing Ctrl+X or the Delete key. The broken connection appears as a red dotted line.
When you delete a block that has one input and one output, a blue line appears to suggest a connection between the broken lines. Click the blue line to connect the signals.
Add a To Workspace block at the end of the broken connection. The To Workspace block outputs the results to a variable in the MATLAB workspace.
Add a Sine Wave block to the model and set the amplitude to
5. Place it to the left of the subsystem.
Add another input to the subsystem. Drag a line from the new Sine Wave block to the left side of the subsystem. A new port appears on the subsystem.
Alternatively, click the side of the block and select the type of port to create.
For certain blocks, these actions add an input port or output port. For example, a port appears on a subsystem when you connect a line to it. Other blocks that add ports include the Bus Creator, Scope, Add, and Product blocks.
Add an output to the subsystem. Add another To Workspace block to the model and place it to the right of the subsystem. Drag a line from its input port to the right side of the subsystem. A new port appears on the subsystem.
Open the subsystem and rename the Out2 block Workspace. Add a Manual Switch block to the subsystem. Resize it and connect it as shown. Branch the signal after the Gain block to direct the output to the To Workspace block.
Then, return to the top level of the model. The figure shows the current model.
Simulate the model.
out variable appears in the MATLAB workspace. Double-click the variable to explore the results.
If you want to use the second sine wave as the input to the subsystem, open the subsystem and double-click the switch. The input changes to the In2 block. Simulate again.
To simulate the model without the effects of the Bias block, right-click the Bias block and select Comment Through. The block stays in the model, but does not affect the operation. Right-click the Bias block and select Uncomment to enable the block. The Comment Out command comments out the block output signal, so signal data does not pass through.
You can use the Comment Out and Comment Through commands in Simulink® to exclude blocks from simulation without physically removing the blocks from the model.
Comment Out: Excludes the selected block from simulation. The signals are terminated and grounded. When you comment out a block, the signal names at the output port of the block are ignored. To include such signals during simulation, add the signal name at the input port of the block.
Comment Through: Excludes the selected block from simulation. The signals are passed through. To comment through, a block must have the same number of input and output ports and no control or connection ports.
To comment out or comment through, right-click the block and select Comment Out or Comment Through based on your modeling requirement. Alternatively, select the block and press Ctrl+Shift+X to comment out, or press Ctrl+Shift+Y to comment through.
These Simulink blocks do not support the Comment Out and Comment Through commands:
Data Store Memory
Goto Tag Visibility
The Signal Generator block does not support the Comment Through command.