% MATLAB contains functions to calculate the natural logarithm (log), the % logarithm to the base 10 (log10), and the logarithm to the base 2 % (log2). However, if you want to find a logarithm to another base - for % example, base b - you'll have to do the math yourself with the formula logb(x) = loge(x)/loge(b)
@phi
what is the question?
how do i find another logarithm to another base using the formula above?
if you want to find a logarithm to another base - for % example, base b - you'll have to do the math yourself with the formula
in Matlab, log(x) means ln(x) if you want base 2 (for example) you would do log(x)/log(2) we know (I hope) \(\log_2(4) = 2\) on the other hand log(4)/log(2) = 1.38629436111989/0.693147180559945= 2
i am a little confused. If I want base 2 I need to do log(x)/log(2) ?
yes
you can test it on your calculator or in matlab
Here is a function that does what you want % y = logb(x,b) % returns log_base_b(x) function y= logb(x,b) y= log(x)./log(b);
Let me play around with this a bit in matlab. The comment before the last comment I see where you are going.
Join our real-time social learning platform and learn together with your friends!