summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Klemkow <j.klemkow@wemelug.de>2012-05-12 10:46:24 +0200
committerJan Klemkow <j.klemkow@wemelug.de>2012-05-12 10:46:24 +0200
commitf8308571ad5d3828c83e7cb6226429731cad883a (patch)
treea16e931ac96d2813bd00be25690d7cc4b15defa3
parentba33d8ccb58f9bd7ecdd4903067cdf465ad49b84 (diff)
downloaddmc-f8308571ad5d3828c83e7cb6226429731cad883a.tar.gz
dmc-f8308571ad5d3828c83e7cb6226429731cad883a.tar.bz2
dmc-f8308571ad5d3828c83e7cb6226429731cad883a.zip
opt_pred: preallocate matrices.
-rw-r--r--opt_pred.m9
1 files changed, 4 insertions, 5 deletions
diff --git a/opt_pred.m b/opt_pred.m
index 26e8df8..458479e 100644
--- a/opt_pred.m
+++ b/opt_pred.m
@@ -1,16 +1,15 @@
function pred = opt_pred(real_data, pred_list)
- err_list = [];
+ err_list = zeros(size(pred_list, 2), size(real_data, 2));
for i = 1:size(pred_list, 2)
- err_list = [err_list; sum(abs(real_data - pred_list{i}))];
+ err_list(i,:) = sum(abs(real_data - pred_list{i}));
end
[min_err, idx] = min(err_list);
-
- pred = [];
+ pred = zeros(size(real_data));
for i = 1:size(idx, 2)
- pred = [pred pred_list{idx(i)}(:,i)];
+ pred(:,i) = pred_list{idx(i)}(:,i);
end
end