calcH_MAG.m 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. function H_MAG = calcH_MAG(magX,magY,magZ,q0,q1,q2,q3)
  2. %CALCH_MAG
  3. % H_MAG = CALCH_MAG(MAGX,MAGY,MAGZ,Q0,Q1,Q2,Q3)
  4. % This function was generated by the Symbolic Math Toolbox version 5.8.
  5. % 14-Jan-2015 11:09:09
  6. t2 = q0.^2;
  7. t3 = q1.^2;
  8. t4 = q2.^2;
  9. t5 = q3.^2;
  10. t6 = q0.*q3.*2.0;
  11. t8 = t2+t3-t4-t5;
  12. t9 = magX.*t8;
  13. t10 = q1.*q2.*2.0;
  14. t11 = q0.*q2.*2.0;
  15. t12 = q1.*q3.*2.0;
  16. t13 = t11+t12;
  17. t14 = magZ.*t13;
  18. t17 = t2-t3+t4-t5;
  19. t18 = magY.*t17;
  20. t19 = t6+t10;
  21. t20 = magX.*t19;
  22. t21 = q0.*q1.*2.0;
  23. t22 = q2.*q3.*2.0;
  24. t23 = t21-t22;
  25. t24 = magZ.*t23;
  26. t25 = t18+t20-t24;
  27. t7 = tan(t25./(t9+t14-magY.*(t6-q1.*q2.*2.0)));
  28. t15 = t6-t10;
  29. t26 = magY.*t15;
  30. t16 = t9+t14-t26;
  31. t27 = 1.0./t16;
  32. t30 = t25.*t27;
  33. t28 = tan(t30);
  34. t29 = 1.0./t16.^2;
  35. t31 = t28.^2;
  36. t32 = t31+1.0;
  37. t33 = magX.*q1.*2.0;
  38. t34 = magY.*q2.*2.0;
  39. t35 = magZ.*q3.*2.0;
  40. t36 = t33+t34+t35;
  41. t37 = magY.*q1.*2.0;
  42. t38 = magZ.*q0.*2.0;
  43. t39 = t37+t38-magX.*q2.*2.0;
  44. t40 = magX.*q0.*2.0;
  45. t41 = magZ.*q2.*2.0;
  46. t42 = t40+t41-magY.*q3.*2.0;
  47. t43 = magY.*q0.*2.0;
  48. t44 = magX.*q3.*2.0;
  49. t45 = t43+t44-magZ.*q1.*2.0;
  50. H_MAG = [(t7.^2+1.0).*(t27.*t45-t25.*t29.*t42),-t32.*(t27.*t39+t25.*t29.*t36),t32.*(t27.*t36-t25.*t29.*t39),t32.*(t27.*t42+t25.*t29.*t45),0.0,0.0,0.0,0.0,0.0,0.0];