Plotting a line given its slope and one coordinate

46 Ansichten (letzte 30 Tage)
Austin Britton
Austin Britton am 13 Dez. 2019
Bearbeitet: Adam Danz am 13 Dez. 2019
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 Kommentar
Adam Danz
Adam Danz am 13 Dez. 2019
Bearbeitet: Adam Danz am 13 Dez. 2019
" 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.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Star Strider
Star Strider am 13 Dez. 2019
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.

Kategorien

Mehr zu Discrete Data Plots finden Sie in Help Center und File Exchange

Produkte


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by