From 8559c243c5260d5ece652ac5b4986f8c40a95e2d Mon Sep 17 00:00:00 2001 From: neingeist Date: Thu, 2 Oct 2014 22:20:44 +0200 Subject: [PATCH] Normalize features --- ex1/featureNormalize.m | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ex1/featureNormalize.m b/ex1/featureNormalize.m index be3507f..74039c2 100644 --- a/ex1/featureNormalize.m +++ b/ex1/featureNormalize.m @@ -26,9 +26,18 @@ sigma = zeros(1, size(X, 2)); % Hint: You might find the 'mean' and 'std' functions useful. % +mu = mean(X); +sigma = std(X); +% This gives broadcasting warnings, but works, too: +% +% X_norm = (X - mu) ./ sigma; +% +% warning: operator -: automatic broadcasting operation applied +% warning: quotient: automatic broadcasting operation applied +X_norm = bsxfun(@rdivide, bsxfun(@minus, X, mu), sigma); % ============================================================