Summary of Time Tables
Summary function works in the same manner on time tables, as it works on ordinary tables. We pass the timetable object as an input and receive the summary.
In this example, we shall first create a timetable and then shall call the summary function on it.
Matlab
% variables for time table dates = datetime({ '2023-04-20' ; '2023-04-21' ; '2023-04-22' }); temp = [20; 23; 17]; % creating timetable weather = timetable(dates,temp); |
Output:
>> weather
weather =
3x1 timetable
dates temp
___________ ____
20-Apr-2023 20
21-Apr-2023 23
22-Apr-2023 17
Here, we have collected a data of temperatures on three dates. Then we created a timetable named weather. Now, we shall call the summary command in the command window to receive the summary of this timetable.
Matlab
% Code summary(weather) |
Output:
>> summary(weather)
RowTimes:
dates: 3x1 datetime
Values:
Min 20-Apr-2023
Median 21-Apr-2023
Max 22-Apr-2023
TimeStep 24:00:00
Variables:
temp: 3x1 double
Values:
Min 17
Median 20
Max 23
Here we get similar output as of an ordinary table. Since the first column contains datetime data, we get the minimum, maximum and the median value along with a timestamp. For the second column, we receive summary containing the maximum, minimum and median value of the temperatures.
Print summary of table, timetable, or categorical array in MATLAB
MATLAB provides various ways to store and organize data such as tables, categorical arrays, arrays, timetables, vectors, etc. MATLAB deals with big data used for machine learning and other mathematical functions which require different organization of data. For small data it is efficient to take a look at the entire data and summarize it but, the same cannot be done when you are working with big data or binary data(.mat files).
For such situations, MATLAB provides the summary function which returns a brief summary of the data structure passed to it. It must be noted here that the summary function works only on three type of MATLAB objects:
- Table
- Timetable
- Categorical Array/Vector
In this article, we shall see how to use the summary function on the above-mentioned MATLAB objects.