📖 Scenario: You are working on a project to analyze simple system data. You want to understand the difference between using Simulink (a graphical tool) and MATLAB scripting (writing code) to model and analyze data.
🎯 Goal: Build a small data structure in Python to represent system data, then write a script to filter and analyze it, simulating the difference between graphical Simulink modeling and MATLAB scripting.
📋 What You'll Learn
Create a dictionary with system component names and their values
Add a threshold variable to select components above a certain value
Use a dictionary comprehension to filter components above the threshold
Print the filtered dictionary to show the result
💡 Why This Matters
🌍 Real World
Engineers often use Simulink for graphical system modeling and MATLAB scripting for data analysis and automation.
💼 Career
Understanding both Simulink and MATLAB scripting helps in system design, simulation, and data-driven decision making in engineering roles.
Progress0 / 4 steps
1
Create system data dictionary
Create a dictionary called system_data with these exact entries: 'sensor1': 10, 'sensor2': 25, 'actuator1': 15, 'actuator2': 5
Simulink
Hint
Use curly braces {} to create a dictionary with keys and values separated by colons.
2
Set threshold value
Create a variable called threshold and set it to 12
Simulink
Hint
Just assign the number 12 to the variable named threshold.
3
Filter components above threshold
Use a dictionary comprehension to create a new dictionary called filtered_data that contains only the items from system_data where the value is greater than threshold
Simulink
Hint
Use dictionary comprehension syntax: {key: value for key, value in dict.items() if condition}
4
Print filtered data
Write a print statement to display the filtered_data dictionary
Simulink
Hint
Use print(filtered_data) to show the filtered dictionary.
Practice
(1/5)
1. What is the main difference between Simulink and MATLAB scripting?
easy
A. Simulink uses visual blocks; MATLAB scripting uses code.
B. Simulink is only for data analysis; MATLAB scripting is for graphics.
C. Simulink runs faster than MATLAB scripting always.
D. MATLAB scripting cannot create models.
Solution
Step 1: Understand Simulink's approach
Simulink builds models using visual blocks and diagrams.
Step 2: Understand MATLAB scripting's approach
MATLAB scripting creates and analyzes models using code commands.