Plotting a line given its slope and one coordinate

59 vues (au cours des 30 derniers jours)
Austin Britton
Austin Britton le 13 Déc 2019
Modifié(e) : Adam Danz le 13 Déc 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 commentaire
Adam Danz
Adam Danz le 13 Déc 2019
Modifié(e) : Adam Danz le 13 Déc 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.

Connectez-vous pour commenter.

Réponses (1)

Star Strider
Star Strider le 13 Déc 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.

Catégories

En savoir plus sur Discrete Data Plots dans Help Center et File Exchange

Produits


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by