How to add a reference line power law of 1?

3 views (last 30 days)
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!!

Accepted Answer

Star Strider
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
Star Strider on 23 Jun 2022
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

Sign in to comment.

More Answers (0)

Categories

Find more on Graphics Performance in Help Center and File Exchange

Tags

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!