Which statement best describes the main difference between Simulink and MATLAB scripting?
Think about how you build models in each environment.
Simulink models systems using graphical blocks connected by lines, making it easy to visualize system behavior. MATLAB scripting uses text commands to perform calculations and automate tasks.
What is the output of this MATLAB script that runs a Simulink model and extracts a signal?
simOut = sim('simple_model'); result = simOut.get('yout'); disp(result.time(end));
Look at what 'result.time(end)' returns.
The code runs the Simulink model 'simple_model', gets the output signal 'yout', and displays the last time point of the simulation.
Given a Simulink model that outputs a signal named 'speed', which MATLAB command correctly extracts the speed data as a vector?
Remember how to access signal values from simulation output objects.
The 'get' method retrieves the signal object by name, and '.signals.values' accesses the data vector.
What error will this MATLAB script produce?
simOut = sim('model_name');
output = simOut.yout.signals.values;
disp(output);Check how to properly access simulation output signals.
The simOut object does not have 'yout' as a direct property; you must use the 'get' method to access signals by name.
You want to run a Simulink model multiple times with different parameter values and collect the output. Which MATLAB script snippet correctly automates this?
params = [1, 2, 3];
results = [];
for p = params
set_param('model', 'Gain', num2str(p));
simOut = sim('model');
results = [results; simOut.get('yout').signals.values(end)];
end
disp(results);Check how the loop updates parameters and collects outputs.
The script loops over parameters, sets the model parameter each time, runs the simulation, and appends the last output value to 'results'.
