Created
January 19, 2016 01:02
-
-
Save HanaanY/5312362546e3210cd95c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data = load('ex1data2.txt'); % loads from array of 47x3 (x1, x2, y) | |
X = data(:, 1:2); % takes first two columns from the array we loaded | |
X_norm = X; | |
mu = zeros(1, size(X, 2)); % work out mean for each column in X | |
sigma = zeros(1, size(X, 2)); % work out stdev for each column in X | |
for i = 1:size(X,2) | |
mu(1,i) = mean(X(:,i)) % find mean for each column of X | |
sigma(1,i) = std(X(:,i)) % find stdev for each column of X | |
end | |
for i = 1:size(X,2) | |
X_norm(:,i) = [(X_norm(:,i) - mu(1,i)) / sigma(1,i)] % normalise each column | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment