
How to add a reference line power law of 1?
1 view (last 30 days)
Show older comments
Hi MATLAB community.
I can't seem to figure out how to add a reference line of power law 1 or 2 or 3/4 or 1/2 to my data figure.
Something like this:

Many thanks!!
0 Comments
Accepted Answer
Star Strider
on 22 Jun 2022
The power equation is
, so choose independent variable x, slope m, and intercept b and go from there —

pwr_y = @(x,m,b) x.^m .* exp(b);
x1 = 0.1 : 0.1 : 1.5;
m = 1;
b = 10;
y1 = pwr_y(x1,m,b);
x2 = x1/10;
m = 0.5;
b = 1;
y2 = pwr_y(x2,m,b);
x3 = x1*100;
m = 2;
b = 5;
y3 = pwr_y(x2,m,b);
figure
loglog(x1, y1, x2, y2, x3, y3)
grid
axis('equal')
% axis([1E-2 1.1 10 1000])
Only 2 x coordinates are necessary, however I chose a vector to demonstrate that the function draws straight lines on a loglog plot.
.
2 Comments
Star Strider
on 23 Jun 2022
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!