EZ-Plot: Plotting Functions Based on Equations in MATLAB

In summary, the conversation discussed the possibility of plotting a function in Matlab based on the equation that defines it rather than a set of points on the curve. The solution was EZ-Plot, which allows for specifying the defining equation and a domain. This was helpful for the person seeking assistance.
  • #1
danago
Gold Member
1,123
4
Hey.

Im trying to make a plot of a function, and was wondering if there was a way to plot it based on the equation that defines the function rather than a set of points on the curve?

i.e. instead of plot(x,y) for a set of (x,y) coordinates, id like to just specify the defininig equation (eg. sin(x)) and a domain.

Is this possible in matlab?

Sorry if i wasn't clear.
Thanks,
Dan.
 
Physics news on Phys.org

1. How do I plot a function in MATLAB?

To plot a function in MATLAB, you can use the "plot" function and specify the independent variable as the first argument and the dependent variable as the second argument. For example, if you want to plot the function y = x^2, you can use the command "plot(x, x.^2)". You can also add axis labels, a title, and customize the plot using various options.

2. Can I plot multiple functions on the same graph in MATLAB?

Yes, you can plot multiple functions on the same graph in MATLAB by using the "hold on" command. This will allow you to plot multiple functions with different colors or line styles on the same figure. You can use the "legend" function to add a legend to the plot to label each function.

3. How do I change the range of the x-axis or y-axis in a MATLAB plot?

You can change the range of the x-axis or y-axis in a MATLAB plot by using the "xlim" and "ylim" functions. These functions take in two arguments, the lower and upper limits of the desired range, and can be used to zoom in or out on specific parts of the plot.

4. Is it possible to save a plot as an image in MATLAB?

Yes, you can save a plot as an image in MATLAB by using the "saveas" function. This function takes in two arguments, the figure handle and the desired file name, and will save the plot as an image file (e.g. PNG, JPEG, etc.).

5. Can I plot a 3D function in MATLAB?

Yes, you can plot a 3D function in MATLAB by using the "surf" or "mesh" functions. These functions take in three arguments, the x, y, and z values, and will create a 3D surface or mesh plot. You can also add labels, a title, and customize the plot using various options.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
11
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
928
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
14
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
12
Views
3K
Back
Top