Differences between revisions 2 and 3
Revision 2 as of 2025-12-17 19:54:40
Size: 1292
Comment: Change title
Revision 3 as of 2025-12-17 20:18:34
Size: 645
Comment: Cleanup
Deletions are marked like this. Additions are marked like this.
Line 13: Line 13:
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:
The `fsurf` function takes a [[MATLAB/DataTypes#Function_Handle|function handle]] or [[MATLAB/DataTypes#Symbolic_Variable|symbolic expression]] as the first argument, and bounds to render as the second. Note that `[-2,2]` is interpreted as ''[-2 2]x[-2 2]''. Compare to `[-2,2,-5,5]` which is interpreted as ''[-2 2]x[-5 5]''.
Line 35: Line 19:
figure(Name="foo"); figure;
Line 37: Line 21:
view([45,60]);
Line 40: Line 23:
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")
}}}
See also [[MATLAB/FiguresAndRelatedCommands|figures and related commands]].

MATLAB fsurf

The fsurf function creates a 2D graph.


Usage

The fsurf function takes a function handle or symbolic expression as the first argument, and bounds to render as the second. Note that [-2,2] is interpreted as [-2 2]x[-2 2]. Compare to [-2,2,-5,5] which is interpreted as [-2 2]x[-5 5].

syms x y;
plane = 2*x + 10*y - 5;

figure;
fsurf(plane, [-2,2,-2,2]);

See also figures and related commands.


CategoryRicottone

MATLAB/FSurf (last edited 2025-12-17 20:38:22 by DominicRicottone)