From 10c0bcc04421962c4af1b199b01fa7425214492f Mon Sep 17 00:00:00 2001 From: llaltxll Date: Sat, 27 Mar 2021 09:55:17 +0300 Subject: [PATCH] Update featureNormalize.m --- mlclass-ex1/featureNormalize.m | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/mlclass-ex1/featureNormalize.m b/mlclass-ex1/featureNormalize.m index b8a7213..08f734e 100644 --- a/mlclass-ex1/featureNormalize.m +++ b/mlclass-ex1/featureNormalize.m @@ -29,12 +29,15 @@ mu = mean(X) sigma = std(X) -indicies = 1:size(X, 2); +% indicies = 1:size(X, 2); -for i = indicies, - XminusMu = X(:, i) - mu(i); - X_norm(:, i) = XminusMu / sigma(i); -end +% for i = indicies, +% XminusMu = X(:, i) - mu(i); +% X_norm(:, i) = XminusMu / sigma(i); +%end + +% in octave we can just do this: +X_norm = (X .- mu)./sigma; % ============================================================