- Access the run data from SDI using the “Simulink.sdi.getRun” function
- Modify the time data of each signal by iterating through the signals in the run and adjusting their time vectors.
- After modifying the time vectors, the changes should automatically reflect in SDI. If SDI does not automatically refresh, you can manually update or refresh the display.
Simulink Data Inspector offset the time of an entire Run
25 views (last 30 days)
Show older comments
Stephen McLaren
on 7 Oct 2024
Commented: Stephen McLaren
on 21 Nov 2024 at 13:02
I am using Simulink Data Inspector as a general tool to view data from a variety of data loggers and runs on a piece of physical equipment. Overall, I love SDI for rapidly showing many different plots and really great cursors.
What I'd like help with is offseting the time base in a given Run. Because of how data is captured during real running, I cannot guarantee that the event I'm trying to compare between runs happens at the same time.
An example of what I'm trying to do is below:
I've tried a few different thoughts I've had (sorry no code as it was all messing about on Command Window!) with modifying the time base of the timeseries in a given run and it hasn't been sucessfully shown in the SDI.
The specific help I need is:
- Change the time base of a given run. Not resampling, just an addition or subtraction to all time entries
- Update of all the plots with this new time base
I don't need help with:
- Picking the signal or data run to change
- Determining an actual offset to apply
Any help would be gratefully received.
0 Comments
Accepted Answer
Kothuri
on 13 Nov 2024 at 16:50
To Change the time base of a given run by an addition or subtraction to all time entries and update of all the plots with this new time base, you can modify the time data of the “timeseries” objects directly in MATLAB by following the below steps:
You can try the below code:
% Retrieve the run ID (replace with your specific run ID)
runID = Simulink.sdi.getAllRunIDs;
myRun = Simulink.sdi.getRun(runID(end)); % Example: getting the latest run
% Define the time offset (positive or negative)
timeOffset = 5; % Example: offset by 5 seconds
% Iterate through each signal in the run
for i = 1:myRun.SignalCount
signal = myRun.getSignalByIndex(i);
ts = signal.Values; % Get the timeseries object
% Modify the time vector
ts.Time = ts.Time + timeOffset;
% Update the signal with the modified timeseries
signal.Values = ts;
end
You can refer the below documentation link for more info on SDI:
More Answers (0)
See Also
Categories
Find more on Analyze Simulation Results in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!