% un - normalized
% this code is corresponding to 'myscale.m' that is a normalized code.
% Edit by suozi 2017.03.06 HIT.JBM
% QQ:379786867 buaasuozi@126.com
function un_normaldata = un_normal(origdata, scaledata, columnarray, lower, upper)
% input: origdata: the original data
% scaledata: the scaled data normalized by 'myscale.m' or other normalized function
% columnarray: the columns that are going to be unnormalized in the column set of original data
% length(columnarray) = size(scaledata,2)
% lower: the low threshold value of the scale data
% upper: the upper threshold value of the scale data
% output: un_normaldata: the unnormal data based on origdata and scaledata
% NOTE: the scaledata are normalized with respect to column.
if nargin < 3
fprintf('Please input the parameters according the demands of this function.')
return
end
if length(columnarray) ~= size(scaledata,2)
fprintf('The slacedata and columnarray are not accordant.')
return
end
% [m,n] = size(origdata);
% [p.q] = size(scaledata);
% find out the max and min value of each column
maxmin = zeros(2,length(columnarray));
for i = 1:length(columnarray)
index = columnarray(i);
maxmin(1,i) = max(origdata(:,index));
maxmin(2,i) = min(origdata(:,index));
end
% unnormalized
un_normaldata = zeros(size(scaledata));
for j = 1:size(scaledata,1)
un_normaldata(j,:) = (scaledata(j,:) - lower).* (maxmin(1,:) - maxmin(2,:))./ (upper - lower) + maxmin(2,:);
end
end