I had dataset of load for 7 days, 1min time interval and I want to put a threshold value. Now claculate a difference D=(load-Threshold) and this D array should be positive by taking modulus and then a array values 'V' with corresponding to the each load data to minimize the sum of array D all data. How to minimize the sum of all elements of D and find the array values of 'V'.
a = 30;
b = 150;
D = (b-a).*rand(100,1) + a; % load data
Th=110; % threshold
Now I want to minimize the sum of "Diff" and find a corresponding vector V(100*1) vector for all values.