Data is saved to the MATLAB® workspace through a Simulink® Scope block. Set signal and triggering properties only when you are running a real-time application. If you are running a normal or accelerator mode simulation, you can skip this procedure.
After you create a Simulink model and add a Scope block, you can enter the signal and triggering properties for logging to the MATLAB workspace.
This procedure uses the model
(matlab: open_system(docpath(fullfile(docroot, 'toolbox', 'sldrt', 'examples', 'sldrtex_model')))).
It assumes that you have already loaded that model.
In the Simulation window, click Code > External Mode Control Panel.
Click the Signal & Triggering button.
Click the Select
all button. From
Source list, select
manual. From the
X under Signal selection designates
that a signal has been tagged for data collection, and
that the signal has been tagged as a trigger signal.
In the Duration field, enter the number of sample points in a data buffer. Enter a Duration value equal to the total number of sample points that you must collect for a run. For example, if you have a sample rate of 1000 samples/second and a stop time of 10 seconds, enter:
Set the time axis for Simulink Scope blocks equal to the sample interval (in seconds) times the number of points in each data buffer. This setting displays one buffer of data across the entire Simulink Scope plot.
Clear the Limit data points to last check box. See Set Scope Parameters for Logging to Workspace.
For more information, see Set Up an External Mode Communication Channel (Simulink Coder).
In the External Signal & Triggering dialog box, click the Apply or Close buttons for the changes you made to take effect. You do not have to rebuild your real-time application.