-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplotAll2.m
More file actions
110 lines (99 loc) · 3.02 KB
/
Copy pathplotAll2.m
File metadata and controls
110 lines (99 loc) · 3.02 KB
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
103
104
105
106
107
108
109
110
clc
clear all
%% Get MAVLink .mat file
[FileName,PathName,FilterIndex] = uigetfile(...
'C:\Users\Simon\Documents\GitHub\mavgraph\*.mat','MAVLink mat file',datestr(date,'yyyy-mm-dd'));
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 (UTC)', 'FontSize', 16);
title('Throttle', 'FontSize', 20);
catch
disp 'Error plotting throttle'
return
end
%% Plot power
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);
power = zeros(len,1);
for i=1:len
power(i,1) = (mavlink_sys_status_t.voltage_battery(i,2)./1000) .* ...
(mavlink_sys_status_t.current_battery(i,2)./100);
end
plot(mavlink_sys_status_t.voltage_battery(rowStart:rowEnd,1),...
power(rowStart:rowEnd,1));
datetick('x','keepticks');
grid on;
axis tight;
set(gca,'FontSize',14);
ylabel('Power /W', 'FontSize', 16);
xlabel('Time (UTC)', 'FontSize', 16);
title('Power', 'FontSize', 20);
catch
disp 'Error plotting power'
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 (UTC)', '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 (UTC)', 'FontSize', 16);
title('Current', 'FontSize', 20);
catch
disp 'Error plotting current'
return
end
clear FileName PathName FilterIndex;