Advertisement
Guest User

Untitled

a guest
Jul 5th, 2015
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. syms r th ph
  2.  
  3. M = [cos(th)*sin(ph), sin(th)*sin(ph),cos(ph);];
  4. M(2,:) = [-r*sin(th)*sin(ph), r*cos(th)*sin(ph),0];
  5. M(3,:) = [r*cos(th)*cos(ph), r*sin(th)*cos(ph),-r*sin(ph)];
  6.  
  7. invM = simplify(inv(M));
  8.  
  9. syms Fr Fth Fph
  10.  
  11. V = [Fr; Fth; Fph];
  12.  
  13. output = invM*V;
  14.  
  15. display(output)
  16.  
  17. syms r th ph
  18. f = symfun(sym('f(r,th,ph)'),[r th ph]);
  19.  
  20. A = diff(f,r)*cos(th)*sin(ph) + (diff(f,ph)*cos(ph)*cos(th))/r - (diff(f,th)*sin(th))/(r*sin(ph));
  21. B = diff(f,r)*sin(ph)*sin(th) + (diff(f,ph)*cos(ph)*sin(th))/r + (diff(f,th)*cos(th))/(r*sin(ph));
  22. C = diff(f,r)*cos(ph) - (diff(f,ph)*sin(ph))/r;
  23.  
  24. A2 = diff(A,r)*cos(th)*sin(ph) + (diff(A,ph)*cos(ph)*cos(th))/r - (diff(A,th)*sin(th))/(r*sin(ph));
  25. B2 = diff(B,r)*sin(ph)*sin(th) + (diff(B,ph)*cos(ph)*sin(th))/r + (diff(B,th)*cos(th))/(r*sin(ph));
  26. C2 = diff(C,r)*cos(ph) - (diff(C,ph)*sin(ph))/r;
  27.  
  28. L = simplify(A2 + B2 + C2);
  29.  
  30. pretty(L)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement