Isit possible to plot a graph with a contant variable?

1 Ansicht (letzte 30 Tage)
Anjali Visavadia
Anjali Visavadia am 10 Mär. 2016
Bearbeitet: Ced am 10 Mär. 2016
I am trying to plot 1/x, where x is a constant. Is this possible?
  1 Kommentar
dpb
dpb am 10 Mär. 2016
Well yeah, but not a lot of point in doing so it would seem...it would just be a point. What's the problem you're having in doing so?

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Ced
Ced am 10 Mär. 2016
Bearbeitet: Ced am 10 Mär. 2016
Of course. Matlab simply needs to know where to "put the dots", it does not really know what the function "looks like".
Be aware however that the plot function requires an x and y vector of same length for it to create a single line. So, x will contain all the x coordinates, and y will be a constant vector of same length. I will let you figure out how to generate these two elements.
Note 1: For constants, you can also use the "line" function instead of "plot"
Note 2: If you pass a vector and a constant to the plot function it will actually generate a separate "plot" (i.e. axis) for each point. This also works for e.g. a vector and a matrix. Just in case you tried that and wondered why you only get little dots everywhere.

Weitere Antworten (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by