CodeCodeCode

ENGR132: HW03 - energy_name

Mar 30th, 2011
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.57 KB | None | 0 0
  1. function energy = energy_name(mass)
  2.  
  3. %Calculates energy based on given mass(es) using formula E = mc^2.
  4. energy = mass .* (2.9979E8)^2;
  5.  
  6. %Creates a plot with a logarithmicly increasing x axis for mass vs energy.
  7. semilogx(mass, energy, 'red');
  8. xlabel('Mass (kg)');
  9. ylabel('Energy (J)');
  10. title('Energy (J) as a result of mass (kg)');
  11. grid;
  12.  
  13. %energy = energy_name(logspace(0,6,10))
  14. %
  15. %energy =
  16. %
  17. %  1.0e+022 *
  18. %
  19. %  Columns 1 through 7
  20. %
  21. %    0.0000    0.0000    0.0002    0.0009    0.0042    0.0194    0.0899
  22. %
  23. %  Columns 8 through 10
  24. %
  25. %    0.4172    1.9363    8.9874
Advertisement
Add Comment
Please, Sign In to add comment