Skip to content

Instantly share code, notes, and snippets.

@z1nc0r3
Created September 4, 2023 16:49
Show Gist options
  • Save z1nc0r3/57644d8f752ca89f4b1b6b3be28149dd to your computer and use it in GitHub Desktop.
Save z1nc0r3/57644d8f752ca89f4b1b6b3be28149dd to your computer and use it in GitHub Desktop.
Scale Data using Matlab
function [train, test] = scaleData(train, test)
[row, col] = size(train);
normalMax = 1;
normalMin = -1;
for i=1:(col-1)
realMax = max(train(:, i));
realMin = min(train(:, i));
ratio = (normalMax - normalMin) / (realMax - realMin);
train(:, i) = (ratio * (train(:, i) - realMin)) + normalMin;
test(:, i) = (ratio * (test(:, i) - realMin)) + normalMin;
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment