fplot

Plots a function of one variable, or a parametric curve, from a handle over an interval.

Category: Graphics > 2-D and 3-D Plots

Syntax

fplot(f)

Plots y = f(x) over the default interval [-5 5].

fplot(f, [xmin xmax])

Plots over the given interval.

fplot(funx, funy, [tmin tmax])

Plots the parametric curve x = funx(t), y = funy(t).

fplot(___, LineSpec)

Sets color, line style and marker, as in plot.

fplot(___, Name, Value)

Sets line properties such as 'LineWidth' or 'MeshDensity'.

Description

fplot chooses its own sample points and adds more where the curve changes quickly, so sharp features are drawn smoothly without picking a step size. The function must work element by element, so write x.^2 and not x^2.

The axes limits follow the interval, which makes fplot handy for looking at a formula before sampling it yourself.

Input arguments

f
Function handle that accepts a vector and returns a vector of the same size.
[xmin xmax]
Interval to plot.
'MeshDensity'
Number of initial sample points; the function adds points where the curve bends.

Example

Two functions

fplot(@(x) sin(x)./x, [-20 20])
hold on
fplot(@(x) 1./x, [1 20], '--')
hold off

In the app, the figure is drawn below the code.

See also

plot fplot3 fimplicit ezplot linspace