how to write log base 2 in matlab coding
3 views (last 30 days)
Show older comments
Prabha Kumaresan
on 8 Nov 2017
Answered: Andrew Rockhill
on 16 Sep 2022
expression for log base 2 in matlab coding
0 Comments
Accepted Answer
More Answers (1)
Andrew Rockhill
on 16 Sep 2022
To find the log in any base, make use of the base-change formula:
log_b(x) = log_a(x)/log_a(b)
So you can create a function logb = @(b,x) log(x)/log(b);
Then Y = logb(2,x);
Or, more generally;
Y = logb(b,x);
0 Comments
See Also
Categories
Find more on Symbolic Math Toolbox 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!