Advertisement
hiddenGem

Line Integral Over a Closed Path ABCA

Nov 19th, 2020
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.97 KB | None | 0 0
  1. %% Line integral over a closed path ABCA
  2. % I haven't figured out a way so that the use only has to enter the vector field 'F' once so you'll just have to just copy and paste it when it asks for it again and again
  3.  
  4. syms t x y z
  5.  
  6. A = input('coordinates for A\n');
  7. B = input('coordinates for B\n');
  8. C = input('coordinates for C\n');
  9.  
  10. v_AB = B-A;
  11. v_BC = C-B;
  12. v_CA = A-C;
  13. v_AB = t.*v_AB;
  14. v_BC = t.*v_BC;
  15. v_CA = t.*v_CA;
  16.  
  17. % Creates parametrized lines for the three lines
  18. c1 =A+v_AB;
  19. c2 =B+v_BC;
  20. c3 =C+v_CA;
  21.  
  22. % Calculates derivative of the three lines
  23. C1 = diff(c1,t);
  24. C2 = diff(c2,t);
  25. C3 = diff(c3,t);
  26.  
  27. % F(c1)
  28. x = c1(1);
  29. y = c1(2);
  30. z = c1(3);
  31. fc1 = input('Vector field\n');
  32.  
  33. % F(c2)
  34. x = c2(1);
  35. y = c2(2);
  36. z = c2(3);
  37. fc2 = input('Vector field\n');
  38.  
  39. % F(c3)
  40. x = c3(1);
  41. y = c3(2);
  42. z = c3(3);
  43. fc3 = input('Vector field\n');
  44.  
  45. % Calculates the individual integrals
  46. a = int(dot(fc1,C1),t,0,1);
  47. b = int(dot(fc2,C2),t,0,1);
  48. c = int(dot(fc3,C3),t,0,1);
  49. a+b+c
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement