Plotting a line given its slope and one coordinate

59 次查看(过去 30 天)
I would like to plot a line given that its slope is roughly 1.08 and it passes through the point (88,56). I do not know the y-intercept and I would prefer not to calculate it as I have many lines for which I'd like to do this, each with their own intercept and slope.
  1 个评论
Adam Danz
Adam Danz 2019-12-13
编辑:Adam Danz 2019-12-13
" I do not know the y-intercept and I would prefer not to calculate it"
You'll have to calculate something. One option is to plot a line segment in which case you'd need to use the slope to calculate a 2nd endpoint in addition to (88,56). Another option is to plot a line by calculate the y-intercept based on the slope and your known coordinate. The latter makes more sense.

请先登录,再进行评论。

回答(1 个)

Star Strider
Star Strider 2019-12-13
Try this:
x = 88;
y = 56;
slope = 1.08;
y_intercept = y - slope*x;
xv = [0 100];
figure
plot(xv, slope*xv+y_intercept, '-r')
hold on
plot(x, y, '+g', 'MarkerSize',15)
hold off
grid
Maker appropriate changes to get the result you want.

类别

Help CenterFile Exchange 中查找有关 Discrete Data Plots 的更多信息

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by