How to normalize a vector considering both maximum and the sum of values?
3 views (last 30 days)
For instance; I have a vector
The maximum is 9300 and the sum is 84137. Now I need to normalize this vector so that I get the same shape pattern for a new maximum (say 9900) and new sum (say 8700).
Kaashyap Pappu on 23 Dec 2019
You can use the normalize function with the ‘range’ method to preserve the shape of your normalized plot. This will consider values in the range [a,b] where a is the minimum value and b is the maximum value. The other methods could also be used as needed.
Hope this helps!
Andrei Bobrov on 23 Dec 2019
Please run follow m - file:
SN = 8700;
Nmx = 9900;
nmn = fzero(@(x)func1(x,Nmx,SN,A),-10000);
[~,N] = func1(nmn,Nmx,SN,A);
function [dt,N] = func1(Nmn,Nmx,SN,A)
mn = min(A);
N = (Nmx - Nmn)/(max(A) - mn)*(A - mn) + Nmn;
dt = sum(N) - SN;
Here N - your output vector.