aboutsummaryrefslogtreecommitdiff
path: root/unittests/data/fit_linear_voltage.m
blob: 7d0c2c27fc3baa1a64fa1209a1673bc941ebd655 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
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)