Using Sink Blocks in Simulink: Scope, Display, and To Workspace
📖 Scenario: You are working on a simple Simulink model to observe and save the output of a signal generated by a sine wave block. You want to see the signal graphically, view its numeric values, and save the data for later analysis.
🎯 Goal: Build a Simulink model that uses three sink blocks: Scope to visualize the signal, Display to show numeric values, and To Workspace to save the signal data to the MATLAB workspace.
📋 What You'll Learn
Create a sine wave source block with frequency 1 Hz and amplitude 1
Add a Scope block connected to the sine wave output
Add a Display block connected to the sine wave output
Add a To Workspace block connected to the sine wave output with variable name 'sineData'
Run the simulation for 2 seconds
💡 Why This Matters
🌍 Real World
Engineers and data scientists use sink blocks in Simulink to monitor signals during simulations and save data for analysis, which helps in designing and testing control systems.
💼 Career
Understanding sink blocks is essential for roles involving system modeling, simulation, and data analysis in industries like automotive, aerospace, and robotics.
Progress0 / 4 steps
1
Create the sine wave source block
Add a Sine Wave block to your Simulink model. Set its Frequency parameter to 1 and Amplitude parameter to 1. This block will generate the signal you will observe.
Simulink
Hint
Use add_block to add the Sine Wave block and set_param to set its parameters.
2
Add sink blocks: Scope, Display, and To Workspace
Add three sink blocks to your model: a Scope block, a Display block, and a To Workspace block. Connect each block's input to the output of the Sine Wave block. Set the To Workspace block's variable name to 'sineData'.
Simulink
Hint
Use add_block to add each sink block and add_line to connect them to the Sine Wave output.
3
Configure simulation time
Set the simulation stop time to 2 seconds. This controls how long the model runs to generate data.
Simulink
Hint
Use set_param on the model to set the StopTime parameter.
4
Run the simulation and display results
Run the simulation using sim('model'). After the simulation finishes, print the first five rows of the variable sineData saved in the workspace.
Simulink
Hint
Use sim('model') to run the simulation and disp to print the data.
Practice
(1/5)
1. Which Simulink sink block is best for showing a live numeric value during simulation?
easy
A. Display block
B. Scope block
C. To Workspace block
D. Gain block
Solution
Step 1: Understand the purpose of Display block
The Display block shows numeric values updating live during simulation.
Step 2: Compare with other sink blocks
Scope shows graphs, To Workspace saves data, Gain modifies signals, so they don't show live numbers directly.
Final Answer:
Display block -> Option A
Quick Check:
Live numeric value = Display block [OK]
Hint: Display shows live numbers; Scope shows graphs [OK]
Common Mistakes:
Confusing Scope with Display
Thinking To Workspace shows live values
Selecting Gain which is not a sink block
2. Which of the following is the correct way to configure a To Workspace block to save data as a structure?
easy
A. Set 'Save format' to 'Array'
B. Set 'Save format' to 'Timeseries'
C. Set 'Save format' to 'Structure with time'
D. Set 'Save format' to 'Matrix'
Solution
Step 1: Identify the save format options in To Workspace block
To Workspace block allows saving data as Array, Structure with time, Timeseries, or Matrix.
Step 2: Choose the option that saves data as a structure
'Structure with time' saves data as a structure containing time and signals.
Final Answer:
Set 'Save format' to 'Structure with time' -> Option C
Quick Check:
Structure save format = 'Structure with time' [OK]
Hint: Structure format is named 'Structure with time' in To Workspace [OK]
Common Mistakes:
Choosing 'Array' which saves plain arrays
Confusing 'Timeseries' with structure
Selecting 'Matrix' which is not a valid option
3. Given this Simulink model snippet:
Signal -> To Workspace block (Save format: Array)
After simulation, what is the format of the saved data in MATLAB workspace?
medium
A. A numeric array containing signal values only
B. A structure with time and signals fields
C. A timeseries object with time and data
D. A cell array with signal data
Solution
Step 1: Understand 'Array' save format in To Workspace block
When 'Array' is selected, only the signal values are saved as a numeric array without time info.
Step 2: Compare with other formats
Structure and Timeseries formats include time; cell arrays are not used here.
Final Answer:
A numeric array containing signal values only -> Option A
Quick Check:
Save format 'Array' = numeric array [OK]
Hint: Array format saves only values, no time info [OK]
Common Mistakes:
Assuming time is saved with Array format
Confusing Array with Timeseries
Expecting a structure instead of array
4. You added a Scope block but see no graph during simulation. What is the most likely cause?
medium
A. The simulation time is zero
B. The Display block is missing
C. The To Workspace block is set to 'Array' format
D. The Scope block is not connected to any signal
Solution
Step 1: Check Scope block connection
Scope requires a connected signal to display data; no connection means no graph.
Step 2: Evaluate other options
Display block absence doesn't affect Scope; To Workspace format doesn't affect Scope display; simulation time zero means no data but usually simulation runs longer.
Final Answer:
The Scope block is not connected to any signal -> Option D
Quick Check:
Scope needs signal connection [OK]
Hint: Scope shows graphs only if connected to signals [OK]
Common Mistakes:
Thinking Display block affects Scope
Confusing To Workspace settings with Scope display
Ignoring signal connections
5. You want to analyze simulation data after running a model. Which sink block should you use to save the data for MATLAB post-processing, and how should you configure it to include time information?
hard
A. Use Scope block; enable data logging
B. Use To Workspace block; set 'Save format' to 'Structure with time'
C. Use Display block; no configuration needed
D. Use To Workspace block; set 'Save format' to 'Array'
Solution
Step 1: Identify the sink block for saving data
To Workspace block is designed to save simulation data to MATLAB workspace for post-processing.
Step 2: Choose the save format to include time
Setting 'Save format' to 'Structure with time' saves both signal data and time stamps.
Final Answer:
Use To Workspace block; set 'Save format' to 'Structure with time' -> Option B
Quick Check:
Save data with time = To Workspace + 'Structure with time' [OK]
Hint: To save with time, use To Workspace + 'Structure with time' [OK]
Common Mistakes:
Using Display or Scope blocks to save data
Choosing 'Array' format which lacks time info
Not configuring save format properly
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.