Main Content

Refine the Model

You can add blocks to a signal, remove blocks from models, 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.

  1. Add a Bias block to the model and set the Bias parameter to 2.

  2. 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.

  3. 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.

  4. 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.

  5. Add a Sine Wave block to the model and set the amplitude to 5. Place it to the left of the subsystem.

  6. 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.

  7. 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.

  8. 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.

  9. Simulate the model.

    • The 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.

Related Topics