Timetables in MATLAB

MATLAB Tutorial

🕒 Timetables in MATLAB (Advanced)

Timetables are an advanced MATLAB data type designed specifically for time-stamped (time-series) data.

They extend tables by using datetime as row times, making them ideal for sensor data, logs, financial data, experiments, and signals.
MATLAB is developed by MathWorks.


🔹 What Is a Timetable?

A timetable:

  • Stores data indexed by time

  • Each row has a timestamp

  • Each column is a variable (numeric, categorical, string, etc.)

📌 Think of a timetable as a table + time axis.


1️⃣ Creating a Timetable

🔸 Basic Creation


 

Output

Time Temp Hum
____________________ ____ ___
01-Jan-2026 00:00:00 22 60
01-Jan-2026 01:00:00 23 62
01-Jan-2026 02:00:00 24 65
01-Jan-2026 03:00:00 23 63
01-Jan-2026 04:00:00 22 61

2️⃣ Accessing Timetable Data

🔹 Access Variables


 


🔹 Access Rows by Time


 

📌 Powerful feature: index directly by time.


🔹 Access Data Content


 


3️⃣ Time-Based Indexing (Very Important)


 

📌 Extracts data between two timestamps.


4️⃣ Sorting & Checking Time


 


5️⃣ Resampling Time-Series — retime()

Used to change time resolution.

🔸 Hourly → Daily Average


 

📌 Extremely common in sensor & finance data.


6️⃣ Filling Missing Time Data


 

📌 Interpolates missing values.


7️⃣ Synchronizing Multiple Timetables

Used when you have multiple sensors.


 

📌 Aligns data based on time.


8️⃣ Plotting Timetable Data


 

📌 Timetables integrate directly with plots.


9️⃣ Adding & Removing Variables


 


🔟 Convert Between Table & Timetable

🔸 Table → Timetable


 

🔸 Timetable → Table


 

⚠️ Important Notes

  • Row times must be datetime or duration

  • retime() is exclusive to timetables

  • Best data type for time-series analysis

  • Works perfectly with plots & statistics


🎯 Interview Questions: Timetables (Advanced)

🔹 Q1. What is the main difference between table and timetable?

Answer:
Timetable uses time as row index.


🔹 Q2. Which data type is used as row time?

Answer:
datetime or duration.


🔹 Q3. How do you resample time-series data?

Answer:
Using retime().


🔹 Q4. How do you align two timetables?

Answer:
Using synchronize().


🔹 Q5. Which function extracts data between two times?

Answer:
Time-based indexing (TT(t1:t2,:)).


🔹 Q6. Where are timetables commonly used?

Answer:
Sensors, finance, logs, experiments, signals.


Summary

  • Timetables are best for time-series data

  • Support time-based indexing & resampling

  • Powerful functions: retime, synchronize

  • Essential for advanced MATLAB analytics

You may also like...