Plotting a line given its slope and one coordinate

59 visualizzazioni (ultimi 30 giorni)
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 Commento
Adam Danz
Adam Danz il 13 Dic 2019
Modificato: Adam Danz il 13 Dic 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.

Accedi per commentare.

Risposte (1)

Star Strider
Star Strider il 13 Dic 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.

Categorie

Scopri di più su Discrete Data Plots in Help Center e File Exchange

Prodotti


Release

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by