summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Franzke <benjaminfranzke@googlemail.com>2012-05-14 08:44:08 +0200
committerBenjamin Franzke <benjaminfranzke@googlemail.com>2012-05-14 08:44:08 +0200
commit3ba4a2ea40c8ee2c3019778658c662ed30829c9f (patch)
tree0572bf4928a04c31991316dcb970d544cb77a23c
parent1ddc4c5ae33404253b98409206834777274f6cd9 (diff)
downloaddmc-3ba4a2ea40c8ee2c3019778658c662ed30829c9f.tar.gz
dmc-3ba4a2ea40c8ee2c3019778658c662ed30829c9f.tar.bz2
dmc-3ba4a2ea40c8ee2c3019778658c662ed30829c9f.zip
regress: Add an ugly workaround hack for old octave versions
-rw-r--r--regress.m13
1 files changed, 11 insertions, 2 deletions
diff --git a/regress.m b/regress.m
index 4d13c62..89a4e0b 100644
--- a/regress.m
+++ b/regress.m
@@ -1,5 +1,14 @@
function polynom = regress(x, y, degree)
- pot = @(x) x.^[degree:-1:0];
- M = reshape(cell2mat(arrayfun(pot, x(:)', 'UniformOutput', false)), degree+1, [])';
+ assert(degree == 1 || degree == 2);
+ % doesnt work with old octave versions currently
+ %pot = @(x) x.^[degree:-1:0];
+ %M = reshape(cell2mat(arrayfun(pot, x(:)', 'UniformOutput', false)), degree+1, [])';
+ M = [];
+ if degree == 1
+ M = [ x.^1 x.^0 ];
+ end
+ if degree == 2
+ M = [ x.^2 x.^1 x.^0 ];
+ end
polynom = M \ y(:);
endfunction