Assuming vdp is a valid Simulink model and simulation runs successfully.
medium
A. The total simulation time
B. An error because open_system does not run the model
C. The last data value from the first logged signal of the simulation
D. The initial value of the simulation signal
Solution
Step 1: Understand commands
open_system('vdp') opens the model, sim('vdp') runs it, and logsout.getElement(1).Values.Data(end) accesses the last data point of the first logged signal.
Step 2: Interpret output
The command returns the final value of the first signal logged during simulation.
Final Answer:
The last data value from the first logged signal of the simulation -> Option C
Hint: Ensure model file is in current folder or path [OK]
Common Mistakes:
Assuming open_system must be called before sim
Thinking sim only works on built-in models
Believing model names must be uppercase
5. You want to programmatically change the value of a block parameter named Gain in a Simulink model controlSys before running the simulation. Which sequence of commands correctly does this?
hard
A. load_system('controlSys'); set_param('controlSys', 'Gain', '5'); sim('controlSys');
B. open_system('controlSys'); set_param('Gain', 'Gain', 5); sim('controlSys');
C. sim('controlSys', 'Gain', 5);
D. set_param('controlSys/Gain', 'Gain', '5'); sim('controlSys');
Solution
Step 1: Identify correct set_param usage
The set_param function requires the full block path and parameter name as strings. 'controlSys/Gain' is the block path, 'Gain' is the parameter, and '5' is the new value as a string.
Step 2: Confirm simulation command
After setting the parameter, sim('controlSys') runs the model with updated parameters.
Final Answer:
set_param('controlSys/Gain', 'Gain', '5'); sim('controlSys'); -> Option D
Quick Check:
set_param with full path + sim() runs updated model [OK]
Hint: Use set_param('model/block', 'param', 'value') before sim() [OK]
Common Mistakes:
Using set_param without full block path
Passing numeric value instead of string for parameter
Trying to pass parameters directly in sim()
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.