z = x2 - y2
How to plot this equation:
x and
y vectors from Step 1. meshgrid to create matrices of all the x squared and y squared values
in proper orientation.
The effect of meshgrid is to create a matrix X with the x-values along each row, and a matrix Y with the y-values along each column. This is done so that it is easy to evaluate a function z=f(x,y) of two variables on the rectangular grid. Click here for an example of how meshgrid works.
mesh(Z); % looks like fishing net
surf(Z); % shows surface in color
contour(Z); % shows contour plot colorbar; % with colorbar
Here is an example of viewing an object from directly overhead:
az = 0;
el = 90;
view(az, el);
Click here for an assortment of general 2D and 3D plotting examples.
In this problem we will review recursion and write a couple of recursive MATLAB functions.
|
x^0 = 1.0 |
for all x |
|
x^n = x * x^(n-1) |
for n>0 |
|
x^n = x^(n/2) * x^(n/2) |
for even n values |
|
x^n = x * x^(n/2) * x^(n/2) |
for odd n values |
capitalize(), that takes a string as input, and returns it with all letters in capital case.