function output_data = unit_scale_data_catch(data) % % function output_data = unit_scale_data_catch(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. This version % wraps the line in question with a try/catch, which allows the program to % proceed from a dbstop. % % compute min and max. data_max = max(data); data_min = min(data); % copy the input data output_data = data; try % 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); catch disp('Error during data rescaling') end