Bird
Raised Fist0
Simulinkdata~10 mins

Creating a new model in Simulink - Visual Walkthrough

Choose your learning style10 modes available
Concept Flow - Creating a new model
Open Simulink
↓
Click New Model
↓
Blank Model Window Opens
↓
Add Blocks
↓
Connect Blocks
↓
Save Model
↓
Model Ready for Simulation
This flow shows the steps to create a new Simulink model: open Simulink, start a new model, add and connect blocks, then save.
Execution Sample
Simulink
simulink;
new_system('myModel');
open_system('myModel');
add_block('simulink/Sources/Sine Wave','myModel/SineWave');
add_block('simulink/Sinks/Scope','myModel/Scope');
add_line('myModel','SineWave/1','Scope/1');
This code opens Simulink, creates a new model named 'myModel', adds a Sine Wave source and a Scope sink, then connects them.
Execution Table
StepActionEvaluationResult
1Open Simulinksimulink;Simulink environment opens
2Create new model 'myModel'new_system('myModel');Blank model 'myModel' created
3Open model windowopen_system('myModel');Model window for 'myModel' opens
4Add Sine Wave blockadd_block('simulink/Sources/Sine Wave','myModel/SineWave');Sine Wave block added to model
5Add Scope blockadd_block('simulink/Sinks/Scope','myModel/Scope');Scope block added to model
6Connect Sine Wave to Scopeadd_line('myModel','SineWave/1','Scope/1');Line connects output of Sine Wave to input of Scope
7Model readyModel has blocks and connectionsReady for simulation
💡 All blocks added and connected, model is ready for simulation
Variable Tracker
VariableStartAfter Step 2After Step 4After Step 5After Step 6Final
Model NameNone'myModel''myModel''myModel''myModel''myModel'
BlocksNoneNoneSineWaveSineWave, ScopeSineWave, ScopeSineWave, Scope
ConnectionsNoneNoneNoneNoneSineWave->ScopeSineWave->Scope
Key Moments - 3 Insights
Why do we need to open the model window after creating it?
Creating the model with new_system only makes it in memory; open_system shows the model window so you can see and edit it (see execution_table step 3).
What does add_line do exactly?
add_line connects output port of one block to input port of another, making signal flow possible (see execution_table step 6).
Can we add blocks before creating the model?
No, the model must exist first to add blocks inside it (see variable_tracker showing model name after step 2).
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the result after step 4?
AScope block added to model
BSine Wave block added to model
CModel window opens
DLine connects blocks
💡 Hint
Check the 'Result' column for step 4 in the execution_table
According to variable_tracker, when do connections appear in the model?
AAfter Step 2
BAfter Step 4
CAfter Step 6
DAfter Step 5
💡 Hint
Look at the 'Connections' row in variable_tracker after each step
If we skip open_system, what happens to the model window?
AModel window does not open
BBlocks cannot be added
CModel window opens automatically
DModel is deleted
💡 Hint
See execution_table step 3 about opening the model window
Concept Snapshot
Creating a new Simulink model:
1. Use new_system('modelName') to create.
2. Use open_system('modelName') to open window.
3. Add blocks with add_block(blockPath, 'modelName/blockName').
4. Connect blocks with add_line('modelName','srcPort','dstPort').
5. Save and simulate the model.
Full Transcript
To create a new Simulink model, first open Simulink environment. Then create a new model using new_system with a name. Open the model window with open_system to see and edit it. Add blocks like Sine Wave and Scope using add_block. Connect these blocks with add_line to define signal flow. After these steps, the model is ready for simulation.

Practice

(1/5)
1. What is the first step to create a new model in Simulink?
easy
A. Use new_system to create a new model.
B. Use simulink.open_system to open an existing model.
C. Add blocks directly without creating a model.
D. Save the model before creating it.

Solution

  1. Step 1: Understand model creation functions

    The function new_system is used to create a new empty model in Simulink.
  2. Step 2: Differentiate from opening models

    open_system opens existing models but does not create new ones.
  3. Final Answer:

    Use new_system to create a new model. -> Option A
  4. Quick Check:

    New model creation = new_system [OK]
Hint: Remember: new_system creates, open_system opens [OK]
Common Mistakes:
  • Confusing new_system with open_system
  • Trying to add blocks before creating a model
  • Assuming saving creates a model
2. Which of the following is the correct syntax to create and open a new Simulink model named 'myModel'?
easy
A. simulink.create_system('myModel'); simulink.show_system('myModel');
B. simulink.open_system('myModel'); simulink.new_system('myModel');
C. new_system('myModel'); open_system('myModel');
D. simulink.new_system('myModel'); simulink.open_system('myModel');

Solution

  1. Step 1: Identify correct function names

    The correct functions are new_system to create and open_system to open the model.
  2. Step 2: Check function order and syntax

    Create the model first, then open it. new_system('myModel'); open_system('myModel'); follows this order and uses correct function names and syntax.
  3. Final Answer:

    new_system('myModel'); open_system('myModel'); -> Option C
  4. Quick Check:

    Create then open = new_system('myModel'); open_system('myModel'); [OK]
Hint: Create first, then open with correct function names [OK]
Common Mistakes:
  • Using open_system before new_system
  • Using incorrect function names like create_system
  • Using incorrect 'simulink.' prefix
3. What will be the output of the following code snippet?
modelName = 'testModel';
new_system(modelName);
open_system(modelName);
blocks = find_system(modelName, 'Type', 'Block');
numBlocks = length(blocks);
What is the value of numBlocks right after running this code?
medium
A. 0
B. 1
C. An error occurs because the model is empty
D. Undefined variable error

Solution

  1. Step 1: Understand model creation and block count

    After creating and opening a new model, it contains no blocks by default.
  2. Step 2: Use find_system to count blocks

    find_system with 'Type'='Block' returns all blocks. Since none are added, the list is empty, so length is 0.
  3. Final Answer:

    0 -> Option A
  4. Quick Check:

    New model has zero blocks [OK]
Hint: New model starts empty, so block count is zero [OK]
Common Mistakes:
  • Assuming default blocks exist
  • Expecting an error for empty model
  • Confusing blocks with system components
4. Consider this code snippet:
open_system('newModel');
new_system('newModel');
What is the main issue with this code when creating a new model?
medium
A. There is no issue; this code works fine.
B. The model is created twice, wasting memory.
C. The model name is invalid for Simulink.
D. The model is opened before it is created, causing an error.

Solution

  1. Step 1: Analyze function order

    The code tries to open a model named 'newModel' before creating it, which causes an error because the model does not exist yet.
  2. Step 2: Understand correct sequence

    The correct sequence is to create the model first with new_system, then open it.
  3. Final Answer:

    The model is opened before it is created, causing an error. -> Option D
  4. Quick Check:

    Open before create causes error [OK]
Hint: Always create before opening a model [OK]
Common Mistakes:
  • Opening a model before creation
  • Assuming open_system creates the model
  • Ignoring error messages
5. You want to programmatically create a new Simulink model named 'controlSystem', add a Gain block, and open the model for editing. Which sequence of commands correctly achieves this?
hard
A. simulink.open_system('controlSystem'); add_block('simulink/Commonly Used Blocks/Gain', 'controlSystem/Gain1'); simulink.new_system('controlSystem');
B. new_system('controlSystem'); add_block('simulink/Commonly Used Blocks/Gain', 'controlSystem/Gain1'); open_system('controlSystem');
C. add_block('simulink/Commonly Used Blocks/Gain', 'controlSystem/Gain1'); simulink.new_system('controlSystem'); simulink.open_system('controlSystem');
D. simulink.new_system('controlSystem'); simulink.open_system('controlSystem'); add_block('simulink/Commonly Used Blocks/Gain', 'controlSystem/Gain1');

Solution

  1. Step 1: Create the new model first

    Use new_system('controlSystem') to create the model before adding blocks.
  2. Step 2: Add the Gain block to the model

    Use add_block with the correct source and destination path inside the new model.
  3. Step 3: Open the model for editing

    Finally, open the model window with open_system('controlSystem') to see and edit it visually.
  4. Final Answer:

    new_system('controlSystem'); add_block('simulink/Commonly Used Blocks/Gain', 'controlSystem/Gain1'); open_system('controlSystem'); -> Option B
  5. Quick Check:

    Create, add block, then open model [OK]
Hint: Create model, add blocks, then open model [OK]
Common Mistakes:
  • Adding blocks before creating the model
  • Opening model before adding blocks
  • Incorrect block path in add_block
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard