aboutsummaryrefslogtreecommitdiff
path: root/unittests/data/fit_linear_voltage.m
diff options
context:
space:
mode:
authorLorenz Meier <lm@inf.ethz.ch>2014-12-20 13:54:58 +0100
committerLorenz Meier <lm@inf.ethz.ch>2014-12-20 13:54:58 +0100
commit6e0cf5002914e9045082bdfe1d3acc484a37f7fb (patch)
treedceede05053ad0fb51e641e7e26509b4d1309dee /unittests/data/fit_linear_voltage.m
parent19d5383c56b78132e63ea30ef1625b0aaa4a0dee (diff)
downloadpx4-firmware-6e0cf5002914e9045082bdfe1d3acc484a37f7fb.tar.gz
px4-firmware-6e0cf5002914e9045082bdfe1d3acc484a37f7fb.tar.bz2
px4-firmware-6e0cf5002914e9045082bdfe1d3acc484a37f7fb.zip
Move unittests into a more perceivable directory
Diffstat (limited to 'unittests/data/fit_linear_voltage.m')
-rw-r--r--unittests/data/fit_linear_voltage.m14
1 files changed, 14 insertions, 0 deletions
diff --git a/unittests/data/fit_linear_voltage.m b/unittests/data/fit_linear_voltage.m
new file mode 100644
index 000000000..7d0c2c27f
--- /dev/null
+++ b/unittests/data/fit_linear_voltage.m
@@ -0,0 +1,14 @@
+close all;
+clear all;
+M = importdata('px4io_v1.3.csv');
+voltage = M.data(:, 1);
+counts = M.data(:, 2);
+plot(counts, voltage, 'b*-', 'LineWidth', 2, 'MarkerSize', 15);
+coeffs = polyfit(counts, voltage, 1);
+fittedC = linspace(min(counts), max(counts), 500);
+fittedV = polyval(coeffs, fittedC);
+hold on
+plot(fittedC, fittedV, 'r-', 'LineWidth', 3);
+
+slope = coeffs(1)
+y_intersection = coeffs(2)