Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function [volume, surface_area] = torus_name(inner_radius, outer_radius)
- %Calculates the volume of the torus.
- volume = (1/4) * pi^2 * (inner_radius + outer_radius) * (outer_radius - inner_radius)^2;
- %Calculates the surface area of the torus.
- surface_area = pi^2 * (outer_radius^2 - inner_radius^2);
- % [volume, surface_area] = torus_name(1,2)
- %
- % volume =
- %
- % 7.4022
- %
- %
- % surface_area =
- %
- % 29.6088
- %
- % [volume, surface_area] = torus_name(7,13)
- %
- % volume =
- %
- % 1.7765e+003
- %
- %
- % surface_area =
- %
- % 1.1844e+003
Advertisement
Add Comment
Please, Sign In to add comment