Advertisement
hiddenGem

Diffraction Grating

Jul 26th, 2020
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.53 KB | None | 0 0
  1. %% Diffraction Grating
  2. % Determines the angle at whcih the beam axis will first and second order peak will
  3. % occur
  4.  
  5. % Inputs and Variables
  6. l = input('Number of lines per mm\n');
  7. lambda = input('Wavelength\n');
  8. n = input('Order(s)\n');
  9. a = numel(n);
  10.  
  11. % Outputs and Equations
  12. d = 10^-3/l;
  13. for i = 1:a
  14.     m = n(i);
  15.     theta(i) = asin(m*lambda/d);
  16.     fprintf('Order %i angle:\n',n(i))
  17.     fprintf('%.3f rad\n', theta(i))
  18. end
  19.  
  20. %{
  21. If user inputs multiple orders in [] then calculations will be carried out
  22. for those orders
  23. %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement