From 266d15cbc2dcc897702e77a8f5d6cbc30c15fad7 Mon Sep 17 00:00:00 2001 From: Benjamin Franzke Date: Tue, 10 Apr 2012 22:44:12 +0200 Subject: Add octave script to print plots of products --- display_data.m | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 display_data.m (limited to 'display_data.m') diff --git a/display_data.m b/display_data.m new file mode 100644 index 0000000..4affa96 --- /dev/null +++ b/display_data.m @@ -0,0 +1,29 @@ +for i = [30 45] + p = dlmread(sprintf("products/p%03d", i), " "); + + day = p(:,1); + quantity = p(:,4); + + middle = repmat(mean(p(:,4)), 42, 1); + middle_20 = repmat(mean(p(1:20, 4)), 42, 1); + + [m, n] = regress(day, quantity); + f = @(x) m .* x + n; + + [m, n] = regress(day(1:20), quantity(1:20)); + g = @(x) m .* x + n; + + figure + plot(day, p(:,4), "-;quantity;", + day, middle, "-;Mittelwert;", + day, middle_20, "-;Mittelwert 1-20;", + day, f(day), "-;Regression 1-42;", + day, g(day), "-;Regression 1-20;") + +endfor + +function [m, n] = regress(x, y) + mn = [ x ones(length(x), 1) ] \ y; + m = mn(1); + n = mn(2); +endfunction -- cgit