graph the function, -(x1/2) - (3*x2 / 2) in matlab

To graph the function -(x1/2) - (3*x2 / 2), you can use the ezsurf or surf function in MATLAB.

Here's an example code snippet that generates the graph of the function:

main.m
% define the function
fun = @(x1, x2) -(x1/2) - (3*x2/2);

% create a grid of points
[x1, x2] = meshgrid(-10:.5:10);

% evaluate the function at each point on the grid
z = fun(x1, x2);

% generate the graph
surf(x1, x2, z)
xlabel('x1')
ylabel('x2')
zlabel('f(x1, x2)')
269 chars
15 lines

This will create a 3D surface plot of the function.

related categories

gistlibby LogSnag