Student Center
View and modify outputs from Simulink and send data to MATLAB
The following exercise demonstrates some of the functionality within MATLAB and Simulink:
- How to view and modify the view of the outputs from a Simulink model within the Simulink viewer (Scope block)
- How to send output data from a Simulink model to the MATLAB workspace
- How to plot data sent from Simulink into the MATLAB workspace
Using the following code:
signals=sin(0:100)';
timein=(0:100)';
simin=[timein signals];
Plot multiple functions on one graph from a Simulink model.
Solving the problem:
This can be accomplished in a number of ways. We can create a model that demonstrates 3 individual ways in which to perform this functionality.
Lets first create the model:
- Open a new Simulink model
- Drag and drop in a From Workspace block, three Gain blocks, a Mux block, a To Workspace block and two Scope blocks. Connect the signals in the following way:

In order to create this configuration, you will need to make the following modifications:
- Double-click on the individual Gain blocks to specify altering gains of 1,2 and 3
- Double-click on the Mux block and change the Number of inputs to 3.
- Double-click on the To Workspace block and specify to Save format as array
- Double-click on Scope 2 to allow that the block accepts three inputs. The second button from the left is called "Parameters". Click here, and then change the 'Number of axes' to 3 and click on OK.
- Now, we will need to define the original code. At the MATLAB command prompt, type the following:
signals=sin(0:100)';
timein=(0:100)';
simin=[timein signals];
We now have the input vector, simin, defined. In this case, the simin variable is an array that contains both time steps and signal values.
- We are now ready to simulate. Let's set the simulation time to 100. In your model, go to Simulation -> Simulation parameters and set the Stop time to 100. Click OK and then use the Start Simulation menu button to run the simulation. (This button looks like an arrow). Once the Simulation is complete, double-click on the two Scopes to see the first two methods of plotting. You can use the Autoscale button within the menu bar of the scopes to clarify the results:


Store
