The log function does exactly what you want.
log(14 - y)
If you want a base 10 log, you use log10. There is also a log2 function, which gives a base 2 log. Other bases are achieved using the simple relation
log(X)/log(b)
produces a log to the base b. You could write a function for it as:
logb = @(X,b) log(X)/log(b);
logb(9,3)
ans =
2
which is as expected.
Finally, there is the reallog function, which also does the natural log, but it produces an error when the log would have been a complex number.
log(-2)
ans =
0.693147180559945 + 3.14159265358979i
reallog(-2)
Error using reallog
Reallog produced complex result.
But for the more normal case, reallog does the same thing as log.
log(2)
ans =
0.693147180559945
reallog(2)
ans =
0.693147180559945 Answer from John D'Errico on mathworks.com
Videos
MathWorks
mathworks.com › matlabcentral › answers › 1465394-how-do-i-calculate-a-logarithm-of-a-variable-base
How do I calculate a logarithm of a variable base? - MATLAB Answers - MATLAB Central
October 2, 2021 - I saw that calculating log of the base of 10 or e is possible. for an example: after typing log (a,b) - I recieve an ERROR message. I'd like to use "a" as a varying number and change it using a loop until I'll get a good result. "a" can be for an example - 1.05, 1.003.... ... Too many input arguments. ... Sign in to comment. Sign in to answer this question. ... https://www.mathworks.com/matlabcentral/answers/1465394-how-do-i-calculate-a-logarithm-of-a-variable-base#answer_800204
MathWorks
mathworks.com › matlabcentral › answers › 431232-how-to-calculate-the-value-of-natural-log-e-in-matlab
How to calculate the value of natural log 'e' in Matlab? - MATLAB Answers - MATLAB Central
November 21, 2018 - https://www.mathworks.com/matl...f-natural-log-e-in-matlab#comment_640660 ... Thanks. It worked. God bless you. ... Sign in to comment. Sign in to answer this question. Find more on Google in Help Center and File Exchange ... Find the treasures in MATLAB Central and discover how the community can help you! Start Hunting! ... Choose a web site to get translated content where available and see local events and offers. Based on your location, ...
EDUCBA
educba.com › home › data science › data science tutorials › matlab tutorial › matlab log
Matlab log | Learn the different examples of Matlab log
March 8, 2023 - This is how our input and output will look like in the Matlab command window: ... As we can see in the output, we have the log of 4 to the base “e” as 1.3863, which is the same as expected by us.
Call +917738666252
Address Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
MathWorks
mathworks.com › matlabcentral › answers › 59158-how-to-represent-ln-in-matlab
how to represent ln in matlab? - MATLAB Answers - MATLAB Central
January 18, 2013 - The log() function is base-e log. So, to take log of x [mathematicians would usually say ln(x)], just do ... Say more. Does it error (and if so what is the FULL text of the error message)?
MathWorks
mathworks.com › matlab › mathematics › elementary math
Exponents and Logarithms - MATLAB & Simulink
This example shows an interesting graphical approach for discovering whether e^pi is greater than pi^e. You clicked a link that corresponds to this MATLAB command:
MathWorks
mathworks.com › matlab › mathematics › elementary math › exponents and logarithms
log2 - Base 2 logarithm and floating-point number dissection - MATLAB
This MATLAB function computes the base 2 logarithm of the elements of X such that 2Y=X.
EDUCBA
educba.com › home › data science › data science tutorials › matlab tutorial › natural log in matlab
Natural Log in Matlab | Learn How to Compute Natural Log in Matlab
May 31, 2023 - The value of e is given by 2.71828 and it is also denoted by a log. So, we should be careful while using a base in any logarithmic equation. In Matlab, natural logarithm is given by log(y) which represents the natural logarithm of y.
Call +917738666252
Address Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
Top answer 1 of 5
17
Consider this example:
%# some random data
x = 2.^(0:10);
y = rand(size(x));
plot(log2(x), y) %# plot on log2 x-scale
set(gca, 'XTickLabel',[]) %# suppress current x-labels
xt = get(gca, 'XTick');
yl = get(gca, 'YLim');
str = cellstr( num2str(xt(:),'2^{%d}') ); %# format x-ticks as 2^{xx}
hTxt = text(xt, yl(ones(size(xt))), str, ... %# create text at same locations
'Interpreter','tex', ... %# specify tex interpreter
'VerticalAlignment','top', ... %# v-align to be underneath
'HorizontalAlignment','center'); %# h-aligh to be centered

2 of 5
15
You can plot directly using the plot command
plot (log2(x), y)
but then your x ticks will be the logarithm rather than the actual value. You could either just change your label
xlabel('Log (base 2) of quantity X');
or you can redo the ticks manually.
xt = get(gca, 'XTick');
set (gca, 'XTickLabel', 2.^xt);
Or you can be really fancy
xticks = 10:25;
set(gca, 'XTick', xticks);
for j = 1:length(xticks)
xtl{j} = ['2^' num2str(xticks(j))];
end
set(gca, 'XTickLabel', xtl)
which will evenly space the tick marks on the log scale, and label them according to their power of 2
Quora
quora.com › How-do-I-use-natural-logarithm-ln-in-matlab
How to use natural logarithm (ln) in matlab - Quora
You can use directly log(x) in MATLAB to do this . If you want to use logarithm of x to the base 10, you need to use log10(x). ... B.E. in Chemical Engineering, City College of New York (Graduated 2022) ·