Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 2.21 KB | None | 0 0
  1. %Kaitlyne Kramer
  2. %section 002
  3. %Lab10
  4. %note: used textbook and mathworks.com
  5.  
  6. clear
  7. clc
  8.  
  9. %Problem 1: determine how far a free falling object falls in five second
  10. %           intervals for o to 3 minutes. Using array operations calculate
  11. %           a row vector that has the distance the object fell for each of
  12. %           the increments. Make a 2-D array that has the times in the
  13. %           first column and distances in the second.
  14. %input needed: times from 0 to 3 minutes, in five second increments.
  15. %output: a table with the times in the first column and distances in the
  16. %        second.
  17. %processing: the equation for a free-falling object i given by D=1/2gt^2
  18. %            g= 9.8 m/s^2
  19.  
  20.  
  21. g= 9.8;
  22. time = linspace(0,180,37);
  23. distance= 0.5*g *time .^2;
  24. table = [time' , distance']
  25.  
  26. %problem 2: use the input function and prompt the user to enter the side of
  27. %           six cubes. Then, determine the radii of the spheres that have
  28. %           the same surface area as the cubes and then the volume as the
  29. %           cubes.
  30. %input: 6 side of the cubes
  31. %output: radii of the spheres that have the same surface area as the cubes
  32. %        and radii of the spheres that have the same volume as the cubes
  33. %processing: prompt user for side values and then calculate volume and
  34. %            surface area. Using these values, calculate the radius for spheres that
  35. %            would have the same volume as the cube and then the same surface area.  
  36.  
  37. %prompt user for data
  38. prompt = 'please enter a value for the side of the cube';
  39. side1= input(prompt);
  40. side2= input(prompt);
  41. side3= input(prompt);
  42. side4= input(prompt);
  43. side5= input(prompt);
  44. side6= input(prompt);
  45.  
  46. cubes = [side1, side2, side3, side4, side5, side6];
  47.  
  48. %calculate volume and surface area
  49. volume= power(cubes,3);
  50. surfacearea= 6*power(cubes,2);
  51.  
  52. %find radius of spheres with the same volume and surface area as the cube
  53. sameradiusforvolume= power(((volume/pi)*3/4),1/3);
  54.  
  55. sameradiusforSA= power(((surfacearea/(4*pi))),1/2);
  56.  
  57. %display values
  58. disp('Sphere radiuses for spheres with the same volume as the cube are');
  59. disp(sameradiusforvolume);
  60. disp ('Sphere radiuses for spheres with the same surface area as the cube are');
  61. disp (sameradiusforSA);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement