Advertisement
mess0011

physicslabor

Dec 23rd, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. % Visualization of angles and amplitude of magnetic field lines with quiver
  2. % and contour
  3. % made by Samuel Schmidt
  4.  
  5. % this file needs two matrices: winkel/spannungen(with the same dimensions)
  6. % imported into the workspace of matlab
  7. % excel --> csv --> "Home"-Tab: "Import Data": "Numeric Matrix" + rename
  8. %
  9.  
  10. % radians converter
  11. r = 0.0174533;
  12.  
  13. w = zeros(36, 49);
  14. s = zeros(36, 49);
  15.  
  16. % our excel was constructed upside down kinda so we have to flip the
  17. % matrices (note this step might be unnecessary/needs to be changed,
  18. % depending on the imported data)
  19. for i = 1:size(winkel,2)
  20. for j = 0:size(winkel,1)-1
  21. w(36-j,i) = winkel(j+1,i);
  22. end
  23. end
  24.  
  25. for i = 1:size(spannungen,2)
  26. for j = 0:size(spannungen,1)-1
  27. s(36-j,i) = spannungen(j+1,i);
  28. end
  29. end
  30.  
  31. % for some reason the angles are inverted, so we turn them back
  32. w = w + 180;
  33.  
  34. % these two lines are basically from the quiver doc
  35. % but with a radians conversion with r*w
  36. u = cos(r*w);
  37. v = sin(r*w);
  38.  
  39. quiver(u,v)
  40. % hold allows us to plot two plots on top of each other in a quick way
  41. hold on;
  42. % http://matlab.izmiran.ru/help/techdoc/ref/colormap.html
  43. colormap('jet')
  44. % one can possibly set the line "levels" themselves
  45. contour(s)
  46. hold off
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement