This is indeed a fit of a power law, which can be described with the formula y = k * x^tau. If you plot this in a log-log figure, you get a straight line. To retrieve the parameters, you have to take the logarithm of both sides of the equation, and then do a linear fit:
% generate some data with random noise
x = logspace(-.5, 1.5, 100);
y = 42 * x.^0.66;
y = y .* (1 + 0.2 * randn(size(y)));
% do linear fit: log(y) = p(1) * log(x) + p(2)
p = polyfit(log(x), log(y), 1);
% retrieve original parameters
tau = p(1);
k = exp(p(2));
% plot
loglog(x, y, '.', x, k*x.^tau, 'r')
axis([.1 100 10 1000])
legend('data', sprintf('power law fit: y = %.1f * x^{%.2f}', k, tau))
xlabel('Amplitude')
ylabel('Velocity')
Result:
Note that this is just a quick and dirty trick, it probably does not give a result that is statistically correct.
MathWorks
mathworks.com › matlab › graphics › 2-d and 3-d plots › line plots
loglog - Log-log scale plot - MATLAB
This MATLAB function plots x- and y-coordinates using a base-10 logarithmic scale on the x-axis and the y-axis.
MathWorks
mathworks.com › matlabcentral › answers › 761576-log-base-10-plot
log base 10 plot - MATLAB Answers - MATLAB Central
March 3, 2021 - So your plot looks like it has no effect. ... Y_Ps = Co + C1*U_Ps + ... C2*U_Ps.^2 + C3*U_Ps.^3 + C4*U_Ps.^4 + ... C5*U_Ps.^5 + C6*U_Ps.^6 + C7*U_Ps.^7 + ... C8*U_Ps.^8 + C9*U_Ps.^9 + C10*U_Ps.^10 + ... ... You should consider putting all those C values in an array, so you can more easily add or remove values. Sign in to comment. Sign in to answer this question. Find more on Animation in Help Center and File Exchange ... Find the treasures in MATLAB Central and discover how the community can help you!
Videos
MathWorks
mathworks.com › matlabcentral › answers › 88757-how-to-plot-a-graph-in-log-base-10-scale-on-the-x-axis
how to plot a graph in log base 10 scale on the x axis - MATLAB Answers - MATLAB Central
October 1, 2013 - Can anyone help with the proper syntax to plot a graph in log base 10 scale for example with f on the x -axis(log base 10 scale ) and ZB on the y -axis for this expression: for f = [1 4 10...
TutorialsPoint
tutorialspoint.com › matlab › matlab_logarithmic_axes_plots.htm
MATLAB - Logarithmic Axes Plots
In this example, the loglog(X, Y, 'r--o') syntax is used to create a plot with both the x-axis and y-axis on a base-10 logarithmic scale. The LineSpec parameter ('r--o') specifies a red dashed line with circular markers.
MathWorks
mathworks.com › matlabcentral › answers › 196506-log-vs-log10-plot
LOG vs LOG10 plot - MATLAB Answers - MATLAB Central
April 7, 2015 - Up to now, I was using the 'loglog' plot. Is the 'loglog' plot actually a lnx-lny plot? Is there a command for a log10(x)log10(y) plot? Sign in to comment. Sign in to answer this question. ... You are so right..I just had trouble after I recalled that log(x) in Matlab means ln(x) in Maths.
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
MathWorks
mathworks.com › matlabcentral › answers › 401849-how-to-plot-the-log-to-base-10-of-absolute-value-of-a-function-containing-sigma
How to plot the log to base 10 of absolute value of a function containing Sigma (Σ) - MATLAB Answers - MATLAB Central
May 22, 2018 - How to plot the log to base 10 of absolute value... Learn more about graphing, matlab, 3d plots
MathWorks
mathworks.com › matlab › mathematics › elementary math › exponents and logarithms
log10 - Common logarithm (base 10) - MATLAB
Y = log10(X) returns the common logarithm of each element in array X. The function accepts both real and complex inputs. For real values of X in the interval (0, Inf), log10 returns real values in the interval (-Inf ,Inf). For complex and negative real values of X, the log10 function returns ...
MathWorks
mathworks.com › matlabcentral › answers › 282038-how-to-draw-a-log-function
How to draw a log function? - MATLAB Answers - MATLAB Central
May 1, 2016 - Again, I'm trying to do this in matlab, help! ... Hey, no fair, Ahmad! You slipped in a factor of 1.75 on your trial. You have 10.^(-.3+1.75*log10(x)) instead of your original 1+log10(x). Naturally you won’t get a straight line with that. The -.3 doesn’t make it nonlinear, but the 1.75 does. In any case you now know how to plot log10(y) = -.3+1.75*log(x).
MathWorks
mathworks.com › matlab › graphics › 2-d and 3-d plots › line plots
semilogx - Semilog plot (x-axis has log scale) - MATLAB
This MATLAB function plots x- and y-coordinates using a base-10 logarithmic scale on the x-axis and a linear scale on the y-axis.
MathWorks
mathworks.com › matlabcentral › answers › 1721460-how-to-plot-error-bars-in-a-logarithmic-base-10-plot
How to plot error bars in a logarithmic (base 10) plot - MATLAB Answers - MATLAB Central
May 17, 2022 - The ‘loglog’ function plots x- and y-coordinates using a base-10 logarithmic scale on the x-axis and the y-axis. For more information on ‘errorbar’ and ‘loglog’, please refer to the below links to their respective documentations: ...
MathWorks
mathworks.com › symbolic math toolbox › mathematics › mathematical functions
log10 - Log base 10 of symbolic input - MATLAB
... Convert symbolic output to double by substituting for x with a number using subs, and then using double. fLog10 = subs(fLog10,x,5); % x is 5 fLog10 = double(fLog10) ... Input, specified as a number, vector, matrix, or array, or a symbolic number, variable, array, function, or expression.
MathWorks
mathworks.com › matlab › graphics › 2-d and 3-d plots › line plots
semilogy - Semilog plot (y-axis has log scale) - MATLAB
This MATLAB function plots x- and y-coordinates using a linear scale on the x-axis and a base-10 logarithmic scale on the y-axis.
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 - Hi! I tried to calculate a log of a varying base - no success. 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. ...