diff options
author | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2012-04-10 22:44:12 +0200 |
---|---|---|
committer | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2012-04-10 22:44:43 +0200 |
commit | 266d15cbc2dcc897702e77a8f5d6cbc30c15fad7 (patch) | |
tree | 9b2ab47e14e3971990490d2917da259a4ac84c4e /display_data.m | |
download | dmc-266d15cbc2dcc897702e77a8f5d6cbc30c15fad7.tar.gz dmc-266d15cbc2dcc897702e77a8f5d6cbc30c15fad7.tar.bz2 dmc-266d15cbc2dcc897702e77a8f5d6cbc30c15fad7.zip |
Add octave script to print plots of products
Diffstat (limited to 'display_data.m')
-rw-r--r-- | display_data.m | 29 |
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 |