Main Content

Edit and Simulate the Model

You can add blocks to a signal, remove blocks from models, and redraw connections. To modify this model, add a bias to the input to both branches of your model. Also, replace one of the scopes with a different sink. Add more blocks to the subsystem and another output.

  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 using 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 prompt appears between the broken connection lines. Click the prompt to connect the signals.

  4. Add a To Workspace block to the model 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, In2, appears on the subsystem.

    For certain blocks, dragging a line to it adds 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, and Add, Sum, 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, Out2, 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 simout and simout1 variables appear in the MATLAB workspace. Double-click each variable to explore the results.

    • If you want to use the second sine wave as input to the subsystem algorithm, open the subsystem and double-click the switch. The input changes to In2. Simulate again.


    To toggle between simulating the model with and 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’s output signal, so signal data does not pass through. Try each of these commands to better understand their effects.

Related Topics