MATLAB: Can anyone please tell, how can I normalize the magnitude between 0 to 1?? Currently it is varying upto (2*10^6). I want it to vary between 0-1.

communicationplotting histogram for magnitude of rayleigh fading channel

N = 10000000; stepsize = .05;
a = 0:stepsize:4;
% Rayleigh model
% Amplitude plot
Rayleigh_ch = (randn(1,N)+1i*randn(1,N))/sqrt(2);
b = abs(Rayleigh_ch);
%c = b/(stepsize*sum(b));
norma = b - min(b(:))
normA = norma ./ max(norma(:)) %
fig = figure;
hist(normA,a);

Best Answer

The way you have "normalized", the maximum value of normA is 1.
I suspect that what you want is for the sum to be 1, rather than the maximum value. If that is correct, then do
normA = norma ./ sum(norma(:)); %

instead of
normA = norma ./ max(norma(:)); %
Related Question