Documentation

Plot Signal Data Logged to Workspace

To visualize non-real-time simulated data or real-time application data, use the MATLAB® plotting functions.

After running your real-time application and logging data to the MATLAB workspace, you can plot the data.

This procedure uses the model sldrtex_model (matlab: open_system(docpath(fullfile(docroot, 'toolbox', 'sldrt', 'examples', 'sldrtex_model')))). It assumes that you saved your data to the variable ScopeData.

  1. To show the structure of the variable ScopeData, in the MATLAB Command Window, type:

    ScopeData
    
    ScopeData = 
                 time: [10000x1 double]
              signals: [1x1 struct]
            blockName: 'sldrtex_model/Scope'
    

    To list the contents of the structure signals, type:

    ScopeData.signals
    
    ans = 
           values: [10000x1 double]
       dimensions: 1
            label: ''
            title: []
        plotStyle: 1
    
  2. To plot the first 1000 points, type:

    plot(ScopeData.time(1:1000),ScopeData.signals.values(1:1000))
    

    The MATLAB environment plots the first 1000 samples over 0.0000–0.9990 seconds.

  3. The variable ScopeData is not automatically saved to your hard disk. To save the variable ScopeData, type:

    save ScopeData

    The MATLAB environment saves the scope data to the file ScopeData.mat.

Was this topic helpful?