function output_data = unit_scale_data(data) % % function output_data = unit_scale_data(data) % % Scale an input data array so that the entire data range fits into the % unit interval [0, 1]. Specifically, subtract the mean value from the % array, and then divide by the data range (max - min). % % This is intended to be an example of the MATLAB debugger. Note that the % function will fail if the array has more than 1 dimension, because of the % array size mismatch between x and mean(x), when x is more than 1-D. % compute min and max. data_max = max(data); data_min = min(data); output_data = data; % Rescale the data by first subtracting the minimum (the data is shifted to % [0, max-min]), and then dividing by the range (data is scaled to [0,1]) output_data = output_data - data_min; output_data = output_data / (data_max - data_min);