figure output from simulink in discrete mode using stairs in matlab

You can use the stairs function in MATLAB to plot the output data from Simulink when operating in discrete mode. Here's an example:

main.m
% Open the Simulink model
open_system('my_model')

% Set the simulation mode to discrete
set_param('my_model', 'SimulationMode', 'discrete')

% Set the stop time and other simulation parameters as desired
set_param('my_model', 'StopTime', '10', 'FixedStep', '1')

% Simulate the model
sim('my_model')

% Plot the results using stairs
stairs(tout, yout)
353 chars
15 lines

In this example, my_model is the name of your Simulink model, StopTime is the time at which the simulation should stop, and FixedStep is the simulation time step. The output of the simulation is stored in tout and yout, which are passed to stairs to plot the output data.

related categories

gistlibby LogSnag