Plotting a line given its slope and one coordinate
43 ビュー (過去 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
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
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 Center および File Exchange で Discrete Data Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!