From dbe3e4d6c4f021bba19dfec6c94cd42afa94cb46 Mon Sep 17 00:00:00 2001 From: Benjamin Franzke Date: Mon, 7 May 2012 21:25:07 +0200 Subject: display_data: Fix to calculate regression from price and quantity --- display_data.m | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'display_data.m') diff --git a/display_data.m b/display_data.m index 4affa96..86ab7b5 100644 --- a/display_data.m +++ b/display_data.m @@ -1,7 +1,7 @@ for i = [30 45] - p = dlmread(sprintf("products/p%03d", i), " "); + p = dlmread(sprintf('products/p%03d', i), ' '); - day = p(:,1); + day = p(:,3); quantity = p(:,4); middle = repmat(mean(p(:,4)), 42, 1); @@ -14,16 +14,10 @@ for i = [30 45] 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;") + plot(p(:,4), "-;quantity;", + middle, "-;Mittelwert;", + middle_20, "-;Mittelwert 1-20;", + f(day), "-or;Regression 1-42;", + g(day), "-om;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