How could I plot y=(x-2)/(2x+3)?

11 vues (au cours des 30 derniers jours)
Richard Kadar-Nemeth
Richard Kadar-Nemeth le 3 Déc 2016
So far I've got:
x = [-100 : 1 : 100];
y = (x - 2) / (2*x + 3);
plot(x,y, 'r')
grid on, axis equal
When I run it, it brings up the plot but the graph is missing.

Réponse acceptée

Star Strider
Star Strider le 3 Déc 2016
You forgot the dot (.) operator to do element-wise division:
y = (x - 2) ./ (2*x + 3);
↑ ← DOT GOES HERE!

Plus de réponses (2)

Richard Kadar-Nemeth
Richard Kadar-Nemeth le 3 Déc 2016
Oh yes, the dot. I was playing with it but left a space between the dot and the / operator. Thanks for the quick help.
  1 commentaire
Star Strider
Star Strider le 3 Déc 2016
My pleasure.
Leaving a space between the dot and the operator will throw an ‘Unexpected MATLAB operator.’ error.

Connectez-vous pour commenter.


Bhargav k
Bhargav k le 8 Oct 2020
Plot the graph of y = x^2 − 2x − 3.

Catégories

En savoir plus sur Mathematics dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by