Custom Flight Log - change datatype

2 views (last 30 days)
Antoine Dilly
Antoine Dilly on 23 Feb 2021
Commented: Antoine Dilly on 25 Feb 2021
i have one problem with the "Custom Flight Log" example.
after loading the data from a file:
Data = load('xxx.mat');
logData = Data;
Plotter = flightLogSignalMapping;
I need to make the timeAccess function. But inside my Data struct is a time array from the type double (The data is saved as milliseconds)
timeAccess = @(x)x.time;
How can i change the double type to milliseconds type ?
The problem is the data is should not be changed, because it has the right structure (0.0083).
And the fuction:
MS = milliseconds(X)
would change the data.
So how i change only the format to milliseconds ?
i am happy for any help

Answers (2)

Jianxin Sun
Jianxin Sun on 23 Feb 2021
Hi Antoine,
Is your data X == 0.0083 seconds or 0.0083 milliseconds? If it is the former, you can use
timeAccess = @(x)seconds(x.time);
The custom flight log expects a duration type from timeAccess return and the function above converts double type to a duration, such as 0.0083 seconds (8.3 ms).

Antoine Dilly
Antoine Dilly on 23 Feb 2021
Thanks for the fast respond
This was also my first idea:
timeAccess = @(x)seconds(x.time);
But i get some error then i run my code:
Data = load('xxx.mat');
logData = Data;
Plotter = flightLogSignalMapping;
timeAccess = @(x)seconds(x.time);
GPS = @(x)[,x.lon,x.alt];
mapSignal(Plotter, "GPS", timeAccess, GPS);
predefinedPlots = show(Plotter,logData,"PlotsToShow","Compass");
Error using array2timetable (line 86)
The VariableNames property must contain one name for each variable in the table.
Error in uav.internal.log.Analyzer/extract (line 155)
tbls{idx} = array2timetable(v(timeFilter,:), 'RowTimes',
t(timeFilter), ...
Error in uav.internal.log.Analyzer/show (line 177)
signal = obj.extract(source, matchedSignalNames{sIdx}, ts,
Error in flightLogSignalMapping/show (line 318)
handles =, ts, te, plotsToShow);
Error in VisualizeCustomFlightLog (line 12)
predefinedPlots = show(Plotter,logData,"PlotsToShow","Compass");

Sign in to comment.


Find more on Guidance, Navigation, and Control (GNC) in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!