Plotting a line using one point and a slope in the loglog scale
10 views (last 30 days)
Show older comments
I am trying to plot a line in the loglog scale using a given point and a slope but the graph(attached) that I am getting is not correct. This is what I have tha gives me the graph attached.
x = (25081:1000:10000000);
m = -3.62;
x1 = log(25081);
y1 = log(3.046*10^-16);
y = m*(x-x1)+ y1;
loglog(x, y)
0 Comments
Accepted Answer
VBBV
on 29 Nov 2022
x = (25081:1000:10000000);
m = -3.62;
x1 = 25081; % use coordninate
y1 = 3.046e-16;
y = m*(x-x1)+ y1
loglog(x, abs(y)) % log of negative number are not defined
1 Comment
VBBV
on 29 Nov 2022
Since the slope is negative , the y vector will be negative. instead you can use semilogx
x = (25081:1000:10000000);
m = -3.62;
x1 = 25081; % use coordninate
y1 = 3.046e-16;
y = m*(x-x1)+ y1
semilogx(x, y) % considering the slope direction
More Answers (0)
See Also
Categories
Find more on Log Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!