Formulation to Matlab code
显示 更早的评论
How to write this formulation in Matlab:

is it :
for i=1:N
S(i) = -PT(i) * log(PT(i));
end
2 个评论
Dimitris Kalogiros
2019-5-14
What is the base of the logarithm? Is it 10 ? If so, then you must use log10() .
Maroco Sc
2019-5-14
采纳的回答
更多回答(1 个)
Raj
2019-5-14
Since your equation asks for 'log' not 'ln' , I think the code should be:
for i=1:N
S(i) = -PT(i) * log10(PT(i));
end
类别
在 帮助中心 和 File Exchange 中查找有关 Programming 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!