- 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
조회 수: 47 (최근 30일)
이전 댓글 표시
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
채택된 답변
Kothuri
2024년 11월 13일 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:
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Analyze Simulation Results에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!