Home
Home
Apps
Apps
Ask
Ask
Manual
Manual
Share
Share

How to add a domain to a variable when we are using the plot function?


#1

For example, I would like to draw a graph of y=2*x but I just want some part of the full graph. Adding a domain to the variable x is needed, but I tried some ways, they all didn’t work.

So how to use the function to draw the graph like y=2*x and x is ranged from 2 to 4.
[ps. There is something wrong with the uploaded, so I cannot share my picture from my picture library.]


#2

Easy:

 plot(x^2,x=[2,4],window=fit)

The window=fit allows the x & y axes to be scaled independently.


#3

Thanks!!
But It seems that the graph is only displayed in some part. Can the part that I don’t want be erased from the graph which means what the result shows me is a line segment instead of a infinite curve?


#4

i am puzzled by your last question. The Plot command I showed is for the range of 2 to 4 as you asked. There is no “infinite range”. X goes from 2 to 4 and y goes from 4 10 16. (See below).

If you can add code & screen shot, it will make it easier to understand what you are referring to…


#5

Oh! I think I see what you want now. For that you want Parametric Plot.


#6

I recently found a way to do this by messing around. Here is the trick.

Lets use your question as an example;
To restrict the domain of y=2*x where x=[2,4]

Go to Mathstudio and type:
Plot(2x/((x>2)(x<4))
Thats all there is to it!

If you would like to know more on how this works or to use the script I created to make it simple to use, click the DomainPlotv1.math file.

P.S. I uploaded it to the share section (I Think).
Anyway Enjoy! :slight_smile:

DomainPlot v1.math (2.4 KB)


#7

Thank you!! That is exactly what I want!!