How to write log base e in MATLAB?
显示 更早的评论
.png)
I have attached a picture of what i am trying to type in MATLAB. I get an error when i put loge(14-y), so im assuming im typing it wrong and MATLAB cannot understand what i am looking for. Any help would be great, Thank you
4 个评论
Dimitris Kalogiros
2019-10-1
You don't have to define the base. Just write log(14-y).
In matlab , log(x) means ln(x).
jinhu
2023-5-28
In matlab, the general log (without radix) is equivalent to natural logarithm (e). Generally, the legal radix in matlab is only 2 and 10
@jinhu - I'm sorry, but that is a meaningless statement. There is no "legal" radix. If you are thinking 2 is a valid radix, since numbers are stored in binary form, you would be vaguely correct. But 10 would simply not apply, since MATLAB only uses a base of 10 to display the numbers. Nothing is stored as a decimal. Anyway, any log computation has essentially nothing at all to do with the way the numbers are stored internally anyway.
If you are talking about syntactic legality, there are THREE syntactically legal log bases: 2, 10, and e, since we have the functions log2, log10, and log in MATLAB. And, if I had to make a bet, I would seriously bet that the log2 and log10 functions merely encode the simple:
log(x,b) = log(x)/log(b)
They might special case certain values of x, so when x==10, you want log10(10) to be exactly 1.
log10(10) == 1
Walter Roberson
2025-2-26
Weirdly, it appears that on the X64 architecture, the instruction is FYL2X which is Y*log2(X) , with the logic

So you would pre-load the "Y" with 1/(log 2 of the base) and then the instruction would calculate log 2 of the value and multiply it by Y.
There is a related instruction y ∗ log2 (x +1)
But other than that... there does not appear to be any log base e instruction.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
