CodeCodeCode

ENGR132: HW03 - torus_name

Mar 30th, 2011
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.53 KB | None | 0 0
  1. function [volume, surface_area] = torus_name(inner_radius, outer_radius)
  2.  
  3. %Calculates the volume of the torus.
  4. volume = (1/4) * pi^2 * (inner_radius + outer_radius) * (outer_radius - inner_radius)^2;
  5. %Calculates the surface area of the torus.
  6. surface_area = pi^2 * (outer_radius^2 - inner_radius^2);
  7.  
  8. % [volume, surface_area] = torus_name(1,2)
  9. %
  10. % volume =
  11. %
  12. %    7.4022
  13. %
  14. %
  15. % surface_area =
  16. %
  17. %   29.6088
  18. %
  19. % [volume, surface_area] = torus_name(7,13)
  20. %
  21. % volume =
  22. %
  23. %  1.7765e+003
  24. %
  25. %
  26. % surface_area =
  27. %
  28. %  1.1844e+003
Advertisement
Add Comment
Please, Sign In to add comment