Plotting Mathematical Functions
fplot function plots a mathematical function between a given set of axes limits. You can control the x-axis limits only, or both the x- and y-axis limits. For example, to plot the
humps function over the x-axis range
[-5 5], use
You can zoom in on the function by selecting y-axis limits of
You can also pass the function handle for an anonymous function for
fplot to graph, as in
You can plot more than one function on the same graph with one call to
fplot. If you use this with a function, then the function must take a column vector
x and return a matrix where each column corresponds to each function, evaluated at each value of
If you pass an anonymous function consisting of several functions to
fplot, the anonymous function also must return a matrix where each column corresponds to each function evaluated at each value of
x, as in
which plots the first and second functions on the same graph.
Note that the anonymous function
evaluates to a matrix of two columns, one for each function, when
x is a column vector.
|Representing Functions in MATLAB||Minimizing Functions and Finding Zeros|
© 1994-2005 The MathWorks, Inc.