- Create a new variable to store the converted timetable.
- Use the array2timetable function to convert the Timeseries to an array. The first argument to the array2timetable function is the Timeseries array, and the second argument is a vector of row times. The row times can be a vector of datetime or duration values.
- Assign the output of the array2timetable function to the new variable.
Convert Timeseries to Timetable for an R202a version.
조회 수: 13 (최근 30일)
이전 댓글 표시
before Matlab version R2021b, how do we convert a Timeseries to a Timetable?
Can I also get the raw functionf file, so that I make a local function that does that conversion on my laptop?
댓글 수: 0
답변 (1개)
recent works
2023년 9월 4일
ts = timeseries(rand(5,1),[0 10 20 30 40]);
TT = array2timetable(ts,[0 10 20 30 40]);
This code creates a Timeseries array called ts with 5 data points, sampled at 10 second intervals. It then converts ts to a Timetable array called TT. The row times in TT are the same as the sample times in ts.
You can get the raw function file for the array2timetable function from the MathWorks website. The file is located in the following directory:
<MATLAB_ROOT>\toolbox\matlab\datafun\array2timetable.m
Once you have the function file, you can copy it to your laptop and create a local function that does the conversion.
Example
function TT = timeseries2timetable(ts)
% Convert a Timeseries to a Timetable
TT = array2timetable(ts,ts.Time);
end
This function takes a Timeseries array as input and returns a Timetable array as output. The output Timetable array has the same data as the input Timeseries array, and the row times are the same as the sample times in the input Timeseries array.
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!