-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplotAll.m
102 lines (93 loc) · 2.79 KB
/
plotAll.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
clc
clear all
%% Get MAVLink .mat file
[FileName,PathName,FilterIndex] = uigetfile(...
'C:\Users\Simon\Documents\GitHub\mavgraph\*.mat','MAVLink mat file');
if FileName <= 0
return;
end
%% Load
load(strcat(PathName,FileName));
%% Get start and end time
pcStart = input('Enter starting %: ')/100;
pcEnd = input('Enter ending %: ')/100;
%% Create figure
plotRows = 2;
plotCols = 2;
currentPlot = 1;
%figure;
%% Plot throttle
try
subplot(plotRows,plotCols,currentPlot);
currentPlot = currentPlot + 1;
len = length(mavlink_vfr_hud_t.throttle);
rowStart = round(pcStart * len)+1;
rowEnd = round(pcEnd * len);
plot(mavlink_vfr_hud_t.throttle(rowStart:rowEnd,1),mavlink_vfr_hud_t.throttle(rowStart:rowEnd,2));
datetick('x','keepticks');
grid on;
axis tight;
set(gca,'FontSize',14);
ylabel('Throttle /%', 'FontSize', 16);
xlabel('Time (zulu)', 'FontSize', 16);
title('Throttle', 'FontSize', 20);
catch
disp 'Error plotting throttle'
return
end
%% Plot altitude
try
subplot(plotRows,plotCols,currentPlot);
currentPlot = currentPlot + 1;
len = length(mavlink_vfr_hud_t.alt);
rowStart = round(pcStart * len)+1;
rowEnd = round(pcEnd * len);
plot(mavlink_vfr_hud_t.alt(rowStart:rowEnd,1),mavlink_vfr_hud_t.alt(rowStart:rowEnd,2));
datetick('x','keepticks');
grid on;
axis tight;
set(gca,'FontSize',14);
ylabel('Altitude /m MSL', 'FontSize', 16);
xlabel('Time (zulu)', 'FontSize', 16);
title('Altitude', 'FontSize', 20);
catch
disp 'Error plotting airspeed'
end
%% Plot voltage
try
subplot(plotRows,plotCols,currentPlot);
currentPlot = currentPlot + 1;
len = length(mavlink_sys_status_t.voltage_battery);
rowStart = round(pcStart * len)+1;
rowEnd = round(pcEnd * len);
plot(mavlink_sys_status_t.voltage_battery(rowStart:rowEnd,1),mavlink_sys_status_t.voltage_battery(rowStart:rowEnd,2)./1000);
datetick('x','keepticks');
grid on;
axis tight;
set(gca,'FontSize',14);
ylabel('Voltage /V', 'FontSize', 16);
xlabel('Time (zulu)', 'FontSize', 16);
title('Voltage', 'FontSize', 20);
catch
disp 'Error plotting voltage'
end
%% Plot current
try
subplot(plotRows,plotCols,currentPlot);
currentPlot = currentPlot + 1;
len = length(mavlink_sys_status_t.current_battery);
rowStart = round(pcStart * len)+1;
rowEnd = round(pcEnd * len);
plot(mavlink_sys_status_t.current_battery(rowStart:rowEnd,1),mavlink_sys_status_t.current_battery(rowStart:rowEnd,2)./100);
datetick('x','keepticks');
grid on;
axis tight;
set(gca,'FontSize',14);
ylabel('Current /A', 'FontSize', 16);
xlabel('Time (zulu)', 'FontSize', 16);
title('Current', 'FontSize', 20);
catch
disp 'Error plotting current'
return
end
clear FileName PathName FilterIndex;