www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/CreateTimetableFromWorkspaceVariablesExample.m

    %% Create Timetable from Workspace Variables
% Create a timetable from workspace variables that contain times as well as
% temperature, pressure, and wind speed and direction measurements. The values 
% in |Time| become the row times of the timetable. All the other workspace 
% variables become the timetable variables.
Time = datetime({'2015-12-18 08:03:05';'2015-12-18 10:03:17';'2015-12-18 12:03:13'});
Temp = [37.3;39.1;42.3];
Pressure = [30.1;30.03;29.9];
WindSpeed = [13.4;6.5;7.3];
WindDirection = categorical({'NW';'N';'NW'});
TT = timetable(Time,Temp,Pressure,WindSpeed,WindDirection)