Visualizing the shape of a hyperboloid is easier when you can plot it using MATLAB. These three-dimensional quadratic surfaces are often defined with implicit equations. These equations may be of the form x^2/a^2 + y^2/b^2 - z^2/c^2 = 1 (hyperboloids of one sheet), or x^2/a^2 - y^2/b^2 - z^2/c^2 = 1 (hyperboloids of two sheets). Using MATLAB, you can turn these complicated equations into 3-D plots.
Things You'll Need
- Equation of a hyperboloid
Solve the hyperboloid equation for "z" using pencil and paper.
Write a MATLAB function based on your solution for z. The function should take two inputs (x and y) and give one output (z). Write your function using element-wise operators: . instead of for multiplication, ./ instead of / for division, and .^ instead of ^ for exponents.
Use MATLAB's built-in "ezsurf" function to quickly plot your hyperboloid. Ezsurf takes two inputs: the handle to the function you want to plot, and a vector of maximum and minimum x and y coordinates for your plot.
For example: Your function is named "hyp." Its handle is then "@hyp" (without the quotation marks). Plot your hyperboloid between x = -10 and x = 20, and between y = -15 and y = 20. Then the vector of maximum and minimum x and y coordinates would be [-10, 20, -15, 20]. At the MATLAB command line, type "ezsurf(@hyp, [-10, 20, -15, 20]" (without the quotation marks). MATLAB will pop up a 3-D surface plot of your hyperboloid.
If you have to plot many hyperboloids, write two MATLAB functions: one for hyperboloids of one sheet, another for hyperboloids of two sheets. Use variables for the constants a, b, and c, and add these variables as inputs to the function. To use these functions with ezsurf, use an anonymous function handle. The anonymous function gives ezsurf the values for a, b, and c, so ezsurf can give those values to your function.
For example: Write a function called "hyp" which takes inputs (x, y, a, b, c). Use a = 2, b = 3, and c = 4. Your anonymous function handle will be "@(x,y) hyp(x, y, 2, 3, 4)" (without the quotation marks). To plot the hyperboloid between x = -5 and x = 10, and between y = -20 and y = 20, use the syntax "ezsurf(@(x,y) hyp(x, y, 2, 3, 4) [-5 10 -20 20]" (without the quotation marks).
- Photo Credit Comstock/Comstock/Getty Images