image thumbnail

MATLAB Plot Gallery - Function Plot (2)

by

 

24 Feb 2012 (Updated )

Create a line plot from a function

Function_Plot_2

This is an example of how to create an line plot from a function in MATLAB®.

Read about the ezplot function in the MATLAB documentation.

For more examples, go to MATLAB Plot Gallery

% Create a series of lines for the function f(x,y) = y^2 - x^2 + c
figure
ezplot('y^2 - x^2 + 4', [-3 3], [-3 3])
hold on
ezplot('y^2 - x^2 + 2', [-3 3], [-3 3])
ezplot('y^2 - x^2',     [-3 3], [-3 3])
ezplot('y^2 - x^2 - 2', [-3 3], [-3 3])
ezplot('y^2 - x^2 - 4', [-3 3], [-3 3])

% Adjust the colormap to plot the function in blue
colormap([0 0 1])
grid on

% Add title
title('y^2 - x^2 - c = 0 for c = -4, 4')

Contact us