1

I am trying to make a small angle approximation in MATLAB's symbolic toolbox. This is being used for the equations of motion in a spacecraft control simulation (and yes, I need to linearize, I can't leave them in their more exact form). For those unfamiliar, the small quantity approximation does a few main things that I need. For small quantities delta and gamma,

  1. delta times gamma is approximately 0
  2. delta^2 is approximately 0 (same with higher powers)
  3. sin(delta) is approximately delta
  4. cos(delta) is approximately 1

I have tried using MATLAB's taylor function (link here), but it doesn't seem to be doing what I want except in a very specific scenario (which I am sure is coincidental anyway). A test case is presented below:

syms psiX psiY psiZ rGMag mu Ixx Iyy Izz
QLB = [1,psiZ,-psiY;-psiZ,1,psiX;psiY,-psiX,1]; %linearized version of the rotation matrix from the L frame to the B frame
rG_LVLH = [0;0;rGMag]; %magnitude of the rG vector expressed in the L frame
rG = QLB*rG_LVLH
G = 3*mu/rGMag^5 .* [rG(2)*rG(3)*(Izz-Iyy);rG(1)*rG(3)*(Ixx-Izz);rG(1)*rG(2)*(Iyy-Ixx)]; %gravity-gradient torque

The desired output of the above should have the G vector with a 0 in the third component and symbolic variables left in the other two. This particular example doesn't include a trigonometric example, but I can provide if necessary. Thanks.

Publius
  • 11
  • 2
  • The small angle approximation is just a Taylor expansion. I’m sure you can apply that to your symbolic expression. – Cris Luengo Nov 16 '21 at 00:56
  • Can you back up a step and show how you derived your G expression? As written, it will be identically 0 since each element has a factor of rG(1) or rG(2) which are both 0. – James Tursa Nov 17 '21 at 00:18
  • @CrisLuengo you're right, but the way that MATLAB is doing the Taylor expansion doesn't seem to be working (certainly not with the products of small quantities). This is the reason I initially tried to use the `taylor` function. – Publius Nov 17 '21 at 04:34
  • @JamesTursa Good catch - I missed one line and renamed a variable (I tried to shorten things when I put them into this post). The original rG vector that I had is expressed in the wrong frame, so it is rotated using the QBL matrix (which is a direction cosine matrix). This makes the first two terms not zero. Sorry for the confusion. – Publius Nov 17 '21 at 04:36
  • OK, but how did you apply this `taylor` function then? You have `G(1)=-(3*mu*psiX*(Iyy - Izz))/rGMag^3`, you can compute the Taylor approximation for small `psiX`, but it's already linear in that variable, so it will do nothing. `taylor(cos(x),x,0,'Order',2)` correctly returns 1. The function works as expected. – Cris Luengo Nov 17 '21 at 16:09
  • You are saying that you want `psiX*K` to remain `psiX*K`, `psiY*K` to remain `psiY*K`, and `psiX*psiY*K` to become 0? That is not what a Taylor expansion does. -- Replace `psiX` with `cos(phi)` and `psiY` with `sin(phi)`, then the Taylor expansion `taylor(G,phi,0,'Order',2)` returns `-(3*mu*(Iyy - Izz))/rGMag^3`, `-(3*mu*phi*(Ixx - Izz))/rGMag^3` and `(3*mu*phi*(Ixx - Iyy))/rGMag^3`, as expected. – Cris Luengo Nov 17 '21 at 16:17
  • @CrisLuengo I am aware that `taylor` doesn't deal with products of small quantities; that's the reason I am hoping that some sort of linearization function (or algorithm) exists. Linearization would need to accomplish both tasks: reducing the sines and cosines AND making products of these variables 0. – Publius Nov 18 '21 at 00:29

0 Answers0