Videos
The natural log in MATLAB is simply log(x). You're mixing the two:
- log in MATLAB
- log in MuPAD
The error message you get is because the function is not defined. You'll get the same error for this line:
bogus_function(1.23)
??? Undefined function or method 'bogus_function' for input arguments
of type 'double'.
I know it's an old question but as I didn't find a good answer when I was trying to do it so I will write my solution for others.
First there is no implemented function to do ln operation in matlab, but we can make it. just remember that the change formula for log base is
log b (X)= log a (X)/log a (B)
you can check this easily.
if you want to calculate log 2 (8) then what you need to do is to calculate log 10 (8)/log 10 (2) you can find that: log 2 (8) = log 10 (8)/log 10 (2) = 3 So easily if you want to calculate ln(x), all you need is to change the base to the e.
ln(x) = log 10 (x)/log 10 (e)
so, just write that code in matlab
my_ln= log 10 ( number ) / log 10 ( exp(1) );
you can also make it as a function and call it whenever you need it,
function [val] = ln_fun(number)
val = log 10 (number)/ log 10 ( exp(1) );
end
*remember the log general formula → log base (number)