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!
