This should work just fine if you don’t want to use some predefined functions:
una=unique(a);
normhist=hist(a,size(unique(a),2))/sum(hist(a));
figure, stairs(una,normhist)
Una
has only the unique values of a
, normhist
is now between 0
and 1
and it’s the probability of occurring of the individual signal because you divide it by the number of elements included in the data.