How to plot two point out, which is related to x*log2(x) as x->0
2 views (last 30 days)
Show older comments
Now, I am learning Communication System 2, and I try to plot out entropy of binary memoryless source curve.
If I use following codes, there is no 2 points, (0,0) and (1,0). I guess that it is because x->0 but log2(x)->infinity so Matlab go wrong to plot out the points!
So, I want to know how you guys solve this problem, thanks!!!
p0 = 0:0.01:1 ;
p1 = 1 - p0 ;
H = (-1).*p0.*log2(p0) + (-1).*p1.*log2(p1) ;
plot(p0,H) ;
0 Comments
Answers (2)
Walter Roberson
on 4 May 2021
p0 = 0:0.01:1;
syms P0
p1 = 1 - P0 ;
H = (-1).*P0.*log2(P0) + (-1).*p1.*log2(p1) ;
HH = arrayfun(@(P) limit(H,P0,P), p0);
plot(p0,HH) ;
0 Comments
See Also
Categories
Find more on Wireless Communications in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!