how can I plot y=log(2,(2-a)) ?

2 次查看(过去 30 天)
How can I plot y = log(2,(2-a) in matlab: I have written this code but unfortunately I encounter with errors:
a = 0:0.2:1;
C_ro = plot(-(a./2).*log(2,a./2) - ((2 - a)./2).*log(2,(2 - a)./2));
plot(a, C_ro)

采纳的回答

Azzi Abdelmalek
Azzi Abdelmalek 2013-8-26
编辑:Azzi Abdelmalek 2013-8-26
Maybe you want this (if log(2,b)=log(b)/log(2))
a = 0:0.2:1;
C_ro = -(a/2).*log(a/2)/log(2) - ((2 - a)/2).*log((2 - a)/2)/log(2);
plot(a, C_ro)

更多回答(1 个)

Osama AlThahab
Osama AlThahab 2013-8-26
your code is wrong, remove plot from C_ro

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by