Skip to content

Instantly share code, notes, and snippets.

@erogol
Created September 3, 2013 15:06
Show Gist options
  • Save erogol/6425136 to your computer and use it in GitHub Desktop.
Save erogol/6425136 to your computer and use it in GitHub Desktop.
Data normalization columnwise
%
% Normalize data columnwise to reduce different unit's effect
%
function[X_norm, val] = normalize_data(X,val)
% if ~exist('va','var')
% [val,ind] = max(X,[],1);
% end
% X_norm = bsxfun(@rdivide, X, val);
temp = max(X) - min(X); % this is a vector
temp = repmat(temp, [length(a) 1]); % this makes it a matrix
% of the same size as A
X_norm = X./temp; % your normalized matrix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment