Main Content


Get representation of signal in referenced Simulation Data Inspector run


[element,name,idx] = getAsDatastore(dsr,searchIdx) returns a object, along with the element name and index, for the signal specified by the index searchIdx in the Simulation Data Inspector run referenced by the Simulink.sdi.DatastoreRef object dsr.


[element,name,idx] = getAsDatastore(dsr,searchName) returns a representation for one or more signals specified by searchName.


collapse all

To create a run of logged signals, simulate the model sldemo_fuelsys.


Use the Simulink.sdi.Run.getLatest function to get the latest run.

fuelRun = Simulink.sdi.Run.getLatest;

Create a Simulink.sdi.DatasetRef object that references fuelRun.

DSRef_fuelRun = getDatasetRef(fuelRun);

Get the names of the elements in the DatasetRef object.

DSRnames = getElementNames(DSRef_fuelRun)
DSRnames = 16x1 cell
    {'CheckRange'                   }
    {'air_fuel_ratio'               }
    {'speed'                        }
    {'map'                          }
    {'ego'                          }
    {'throttle'                     }
    {'fuel'                         }
    {'EGO Fault Switch:1'           }
    {'Engine Speed Fault Switch:1'  }
    {'MAP Fault Switch:1'           }
    {'Throttle Angle Fault Switch:1'}
    {'ego_sw'                       }
    {'engine_speed'                 }
    {'speed_sw'                     }
    {'map_sw'                       }
    {'throttle_sw'                  }

Get an sdidatastore object for the fuel signal. The sdidatastore object exists in the Values property of the returned Simulink.SimulationData.Signal object.

[fuel_ds,name,idx] = getAsDatastore(DSRef_fuelRun,"fuel")
fuel_ds = 
  Package: Simulink.SimulationData

              Name: 'fuel'
    PropagatedName: ''
         BlockPath: [1x1 Simulink.SimulationData.BlockPath]
          PortType: 'outport'
         PortIndex: 1
            Values: [1x1]

name = 
idx = 7

Input Arguments

collapse all

Run from which to get signal data, specified as a Simulink.sdi.DatasetRef object.

Index of signal in the Simulation Data Inspector run referenced by dsr to get as sdidatastore representation, specified as a positive integer.

Example: 3

Name of signal to get as sdidatastore representation, specified as a string or character vector.

Example: "MySignal"

Output Arguments

collapse all

sdidatastore representation of signal from Simulation Data Inspector run, returned as an object whose Values parameter contains a object, such as a Simulink.SimulationData.Dataset, Simulink.SimulationData.Signal, Simulink.SimulationData.State, or similar object.

Element name, returned as a character vector.

Element index in the Simulation Data Inspector run referenced by the Simulink.sdi.DatasetRef object, returned as a positive integer.


You can construct a sdidatastore object for a specified signal using a object.

Version History

Introduced in R2017b