MATLAB fsurf
The fsurf function creates a 2D graph.
Contents
Usage
The fsurf function takes a variable number of arguments, but two are mandatory. The first is a function handle or equation defined using symbols.
% Plane given by 2x + 10y - z = 5 syms x y; plane = 2*x + 10*y - 5; % Function given by f(x,y) = sin(x) + cos(y) syms x y; func = sin(x) + cos(y);
The second argument is the bounds that will be rendered. Passing [-2,2] causes the render to stretch from -2 to 2 in both x- and y-axes. Passing [-2,2,-5,5] causes the render to stretch from -2 to 2 in the x-axis, but from -5 to 5 in the y-axis.
Generally, it is mandatory to follow the fsurf function with the view function, which sets the camera angle in terms of azimuth and elevation. It is also generally necessary to call the figure function beforehand to create a container.
Altogether, try:
syms x y; plane = 2*x + 10*y - 5; figure(Name="foo"); fsurf(plane, [-2,2,-2,2]); view([45,60]);
Use hold on to accumulate functions into the same graphic. This is then disabled by hold off.
To attach labels, try:
title("foo")
xlabel("x")
ylabel("y")
zlabel("z")