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

2 次查看(过去 30 天)
  1 个评论
Stephen23
Stephen23 2014-12-19
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.

请先登录,再进行评论。

采纳的回答

John D'Errico
John D'Errico 2014-12-19
编辑:John D'Errico 2014-12-19
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).

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Logging 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by