%% ROS Time to MATLAB Time Example
% This example shows how to convert current ROS time into a MATLAB® standard time. The ROS Time object is first converted to a double in seconds, then to the specified MATLAB time.
% Set up ROS network and store ROS time.

rosinit
t = rostime('now');

% Convert ROS time to a double in seconds.

secondtime = double(t.Sec)+double(t.Nsec)*10^-9;

% Set time to a specified MATLAB format.

time = datetime(secondtime, 'ConvertFrom','posixtime')

% Shut down ROS network.

rosshutdown

% Copyright 2019 The MathWorks, Inc.
%