diff options
author | Lorenz Meier <lm@inf.ethz.ch> | 2014-07-21 13:30:56 +0200 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2014-07-21 13:30:56 +0200 |
commit | afff12374240240ec2bbf2ba043b37cca8b3298a (patch) | |
tree | 33b99f26590037f81beccd7c3dd06bef5cc37be6 /Tools/tests-host/data/fit_linear_voltage.m | |
parent | 25d1cc3995f3ecafe2408582296d6dedfe49ce53 (diff) | |
download | px4-firmware-afff12374240240ec2bbf2ba043b37cca8b3298a.tar.gz px4-firmware-afff12374240240ec2bbf2ba043b37cca8b3298a.tar.bz2 px4-firmware-afff12374240240ec2bbf2ba043b37cca8b3298a.zip |
Add PX4IO voltage dataset and linear fit
Diffstat (limited to 'Tools/tests-host/data/fit_linear_voltage.m')
-rw-r--r-- | Tools/tests-host/data/fit_linear_voltage.m | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Tools/tests-host/data/fit_linear_voltage.m b/Tools/tests-host/data/fit_linear_voltage.m new file mode 100644 index 000000000..a0384b486 --- /dev/null +++ b/Tools/tests-host/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)
\ No newline at end of file |