# How to add a reference line power law of 1?

1 view (last 30 days)
Yunan Ye on 22 Jun 2022
Commented: Star Strider on 23 Jun 2022
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!!

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 CommentsShowHide 1 older comment
Star Strider on 23 Jun 2022
My pleasure!
.

R2020b

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!