Main Content

Set Scope Parameters for Logging to File

You save data to a file by first saving the data to the MATLAB®workspace through a Simulink®Scopeblock. For data to be saved, setScopeblock parameters.

After you create a Simulink model and add aScopeblock, you can enter the scope parameters for signal logging to a file.

This procedure uses the modelsldrtex_model. To open this model, in the MATLAB Command Window, type:

open_system(docpath(fullfile(docroot,'toolbox',...'sldrt','examples','sldrtex_model')))

It assumes that you have already loaded that model.

  1. In the Simulink Editor, on theDesktop Real-Timetab, selectMode>Run in Kernel.

  2. In the model diagram, double-click theScopeblock.

  3. On theScopetoolbar, click theParametersbutton.

  4. Click theLoggingtab.

  5. Do one of the following:

    • If you are running a normal mode simulation inConnected IOmode, select theLimit data points to lastcheck box, and enter the number of sample points to save.

    • If you are running an external mode simulation inRun in Kernelmode, do not select theLimit data points to lastcheck box.

    When you are usingSimulink Desktop Real-Time™software, use theDurationvalue to set the number of sample points you save. To set theDurationvalue, seeSet Run in Kernel Mode Properties for Logging to File. For more information, seeExternal Mode Simulation with TCP/IP or Serial Communication(Simulink Coder).

  6. Select theLog data to workspacecheck box. In theVariable nametext box, enter the name of a MATLAB variable. The default name isScopeData.

    In the Scope parameters dialog box, you must select theLog data to workspacecheck box to be able to save data to a file. If you do not select theLog data to workspacecheck box, the MAT-files for data logging are created, but they are empty.

  7. From theSave formatlist, select one of结构与钛me,Structure,Array, andDataset. For example, to save the sample times and signal values at those times, select结构与钛me.

    Image of scope parameters data

  8. ClickOK.

    Before connecting and starting the application with changed settings, rebuild your real-time application. If you do not rebuild after these changes, an error occurs.

Related Topics