error: Undefined function 'log' for input arguments of type 'char' ((i can't determine the error source))

2 views (last 30 days)
  1 Comment
Stephen23
Stephen23 on 19 Dec 2014
The error message states that you are using the function log with a string input, for which it is not defined, as it only operates on floating point numbers. Given that you only use the log function twice, it should be fairly easy to locate which one has a string as its input.

Sign in to comment.

Accepted Answer

John D'Errico
John D'Errico on 19 Dec 2014
Edited: John D'Errico on 19 Dec 2014
Surely you can determine the source.
You have defined s as a string. Yes, that string looks like a number. But still, it is a string. See the difference in these two calls:
log(12)
ans =
2.4849
log('12')
Undefined function 'log' for input arguments of type 'char'.
The log function is not defined to operate on strings, but you did that when you tried to execute the sub-expression log(s). Use log(k1) there instead. Or if you wanted to compute the log of your truncated approximation in the string s, then you will need to convert that number back into a number.
So you might need to use log(str2num(s)) instead of log(s).

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!