summaryrefslogtreecommitdiff
path: root/display_data.m
diff options
context:
space:
mode:
Diffstat (limited to 'display_data.m')
-rw-r--r--display_data.m29
1 files changed, 29 insertions, 0 deletions
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