matlabcastingnatural-logarithm

How do take natural log of a double in MATLAB?


I am attempting to that the natural log of a number, I get the message:

tf2 = 60*ln(B1);

Undefined function 'ln' for input arguments of type 'double'.

So i try to cast the number as a float which the documentation claims it will accept but then i get the error message :

float(B1);

Error using float (line 50)
The input argument to float was not a supported type. The only recognized strings are     'single' and 'double'. The input type was 'double'

So then i try to cast the double as a single and get the same error but it says :

f=single(B1);
float(B1);

Error using float (line 50)
The input argument to float was not a supported type. The only recognized strings are     'single' and 'double'. The input type was 'single'

Solution

  • The natural log in MATLAB is simply log(x). You're mixing the two:

    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'.