-
Notifications
You must be signed in to change notification settings - Fork 13
/
plot_sensors.m
executable file
·68 lines (49 loc) · 1.8 KB
/
plot_sensors.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
#! /usr/local/bin/octave -f
# Octave implementation to plot SensorLogger transformed files to one fie
#
#
# Roemer Vlasveld (roemer.vlaseld@gmail.com)
# Usage: call with paramter directory with accelerometer.csv, rotation.csv etc files
# Output: png plots for each file and multiplot with accelerometer, lin_acceleration,
# magnetic_field and rotation
# Depends on "load_SensorLogger_directory.m" function file, which should be in
# the same directory.
clear all;
source('./load_SensorLogger_directory.m')
# get directory to work on
arg_list = argv();
directory = arg_list{1};
files = load_directory(directory);
# Determine of path already has trailing slash
separator = "";
if substr(directory, -1, 1) != '/'
separator = "/";
end
# Plot normal grahs
for i = 1 : length(files)
clf;
metric = files{i};
size_metric = eval(cstrcat("size(", metric, ", 1)"))
if size_metric > 0
plot_command = cstrcat("plot(", metric, "(:,2),", metric, "(:,3:5), '-')");
lines = eval(plot_command);
print_location = strcat(directory, separator, "_", metric, ".png");
title (strrep(print_location, '_', '\_'));
eval( cstrcat("print -dpng ", print_location, ' "-S1700,800"') );
end
end
# create a multiplot file with acceleromter, lin_acceleration, rotation, magnetic_field
plot_metrics = {'accelerometer', 'lin_acceleration', 'magnetic_field', 'rotation'};
clf;
for i = 1 : length(plot_metrics)
# Set index for this subplot
subplot(length(plot_metrics), 1, i );
metric = plot_metrics{i};
plot_command = cstrcat("plot(", metric, "(:,2),", metric, "(:,3:5), '-')");
lines = eval(plot_command);
title(strrep(plot_metrics{i}, '_', '\_'));
print_location = strcat(directory, separator, "_accumulated.png");
eval( cstrcat("print -dpng ", print_location, ' "-S1700,1200"') );
end
close all;
pause(0.1);