Skip to content

Instantly share code, notes, and snippets.

@nicoandmee
Created February 25, 2022 13:59
Show Gist options
  • Save nicoandmee/4da9e5b8d5dc73c73d0ca8f4de4c5f8d to your computer and use it in GitHub Desktop.
Save nicoandmee/4da9e5b8d5dc73c73d0ca8f4de4c5f8d to your computer and use it in GitHub Desktop.
clc, clear, close all;
format long
mass = [10 20 30 40 50 60].*10^(-3);
elongation = [0.162 0.311 0.47 0.622 0.79 0.931].*10^(-2);
K = 65;
% number of samples
N = length(elongation);
offsets = zeros(size(elongation));
for k = 1:N
f_g = mass(k) * 9.8;
x_m = f_g/K;
offsets(k) = abs(elongation(k) - x_m);
end
x_bar_offset = mean(offsets) * 10^2;
b_x = std(offsets) / sqrt(N)
% corrections = zeros(size(elongation));
% for k = 1:N
% corrections(k) = elongation(k) - x_bar_offset;
% end
% b = (std(corrections) / sqrt(N)) * 10^2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment