Delete signal in the Simulation Data Inspector
This example shows how to use
Simulink.sdi.deleteSignal to create a copy of a run that contains a subset of the signals from the original run. You can use the copy to analyze and run comparisons on a subset of signals while still holding onto the original run that has all of the signals. For example, the model
sldemo_fuelsys is configured to log ten signals. To compare the system's responses to different types of failures, you don't need to run the comparison on all of the logged signals. Deleting signals that do not represent the system's response before running the comparison saves processing time and simplifies the view of the results.
Load the model
sldemo_fuelsys and run simulations to create runs in the Simulation Data Inspector. The first run simulates a failure of the throttle angle sensor, and the second run simulates a failure of the exhaust gas oxygen sensor.
load_system('sldemo_fuelsys') modelWorkspace = get_param('sldemo_fuelsys','modelworkspace'); modelWorkspace.assignin('throttle_sw',0) modelWorkspace.assignin('ego_sw',1) sim('sldemo_fuelsys') modelWorkspace.assignin('throttle_sw',1) modelWorkspace.assignin('ego_sw',0) sim('sldemo_fuelsys')
Copy the Run
Use the Simulation Data Inspector's programmatic interface to get
Simulink.sdi.Run objects for the simulations, and then create copies of the runs.
% Get runs runIDs = Simulink.sdi.getAllRunIDs; runID1 = runIDs(end-1); runID2 = runIDs(end); run1 = Simulink.sdi.getRun(runID1); run2 = Simulink.sdi.getRun(runID2); % Create a copy of each run, truncRun [truncRun1,runIndex1,signalIDs1] = Simulink.sdi.copyRun(runID1); [truncRun2,runIndex2,signalIDs2] = Simulink.sdi.copyRun(runID2);
Delete Signals in Run Copy
sldemo_fuelsys model is configured to log the values of the fault switches along with several signals representing the system's response. When you compare the system's response when a throttle angle sensor fails to its response when an exhaust gas oxygen sensor fails, comparing the fault switch states does not provide new information. Therefore, delete the switch signals before running the comparison to eliminate unnecessary computations.
Simulink.sdi.deleteSignal(signalIDs1(1)) Simulink.sdi.deleteSignal(signalIDs1(3)) Simulink.sdi.deleteSignal(signalIDs1(5)) Simulink.sdi.deleteSignal(signalIDs1(8)) Simulink.sdi.deleteSignal(signalIDs2(1)) Simulink.sdi.deleteSignal(signalIDs2(3)) Simulink.sdi.deleteSignal(signalIDs2(5)) Simulink.sdi.deleteSignal(signalIDs2(8))
Compare Truncated Runs
You can use the truncated runs you created with
Simulink.sdi.deleteSignal to perform a comparison of the system's response to different types of failures. Then, open the Simulation Data Inspector to view the comparison results.
truncRunDiff = Simulink.sdi.compareRuns(truncRun1,truncRun2); Simulink.sdi.view
sigID— Signal or signals to delete
Signal to delete, specified as a scalar signal ID or vector of signal IDs. The Simulation Data Inspector assigns a unique numeric signal ID to each signal when a run is created for logged or imported data.
You can get the signal ID for a signal using one of these functions: