From 6e0cf5002914e9045082bdfe1d3acc484a37f7fb Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sat, 20 Dec 2014 13:54:58 +0100 Subject: Move unittests into a more perceivable directory --- unittests/data/fit_linear_voltage.m | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 unittests/data/fit_linear_voltage.m (limited to 'unittests/data/fit_linear_voltage.m') 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) -- cgit v1.2.3