title: finding difference between two rotation matrices
body: <p>I am having following problem, I have developed code for converting the large array of euler angles to rotation matrices, my data is phi1,phi and phi2 values like as follows </p>
  
  <pre><code>phi1 phi phi2
  2     3   5
  1     2.2  4.3
  3     4    5
  </code></pre>
  
  <p>.....there are other 2 million array of data.</p>
  
  <p>but I want to carry out inverse of the rotation matrix formed from first row of euler angles and multiply it to matrix developed from the second row. Then I have to use one of the elements of the resultant matrix. 
  Is there any way to do that? </p>
  
  <pre><code>g_11=((cosd(phi1).*cosd(phi2))-(sind(phi1).*sind(phi2).*cosd(phi)));
  g_12=((sind(phi1).*cosd(phi2))+(cosd(phi1).*sind(phi2).*cosd(phi)));
  g_13= (sind(phi2).*sind(phi));
  g_21 =((-cosd(phi1).*sind(phi2))-(sind(phi1).*cos(phi2).*cos(phi))); 
  g_22 = ((-sin(phi1).*sind(phi2))+(cosd(phi1).*cosd(phi2).*cosd(phi)));
  g_23 = (cosd(phi2).*sind(phi));
  g_31 = (sind(phi1).* sind(phi));
  g_32 = -cosd(phi1).* sind(phi);
  g_33 = cosd(phi); 
  
  g1 =[g_11 g_12 g_13 ; g_21 g_22 g_23 ; g_31 g_32 g_33]
  </code></pre>
  
  <p>Here g1 is the rotation matrix for first row of the data
  I want to find g2 which is the rotation matrix for second row of the data. thin I want to carry out </p>
  
  <pre><code>del_g= inv(g1).*g2;
  </code></pre>
  
  <p>then I want to extract g11 and g13 elements of the resultant matrix. </p>
  
  <p>The data is taken from a text  file with the following data</p>
  
  <pre><code> 4.55686   0.88751   4.71368      0.00000      0.00000  879.7  0.143  1.77 1 1 Iron - Alpha
    4.57459   0.87938   4.71205     20.00000      0.00000  926.3  0.196  2.13 1 1 Iron - Alpha
    4.57459   0.87938   4.71205     40.00000      0.00000  550.3  0.196  2.13 1 1 Iron - Alpha
    4.57709   0.88250   4.71319     60.00000      0.00000  631.4  0.232  1.85 1 1 Iron - Alpha
    4.57507   0.88371   4.72148     80.00000      0.00000  639.7  0.375  2.10 1 1 Iron - Alpha
    4.57507   0.88371   4.72148    100.00000      0.00000  643.9  0.375  1.86 1 1 Iron - Alpha
    4.57507   0.88371   4.72148    120.00000      0.00000  680.4  0.375  1.75 1 1 Iron - Alpha
    4.57507   0.88371   4.72148    140.00000      0.00000  691.6  0.375  1.81 1 1 Iron - Alpha
    4.57507   0.88371   4.72148    160.00000      0.00000  674.9  0.375  1.66 1 1 Iron - Alpha
    4.58254   0.87567   4.69293    180.00000      0.00000  651.6  0.286  1.95 1 1 Iron - Alpha
    4.58254   0.87567   4.69293    200.00000      0.00000  657.5  0.286  1.92 1 1 Iron - Alpha
    4.58254   0.87567   4.69293    220.00000      0.00000  693.4  0.286  2.18 1 1 Iron - Alpha
    4.58254   0.87567   4.69293    240.00000      0.00000  670.5  0.286  2.06 1 1 Iron - Alpha
  </code></pre>
  
  <p>The first three columns are the euler angles phi1,phi and phi2 respectively
  for extracting the data from the text file I am using</p>
  
  <pre><code>fid = fopen('test.txt');
  A =  textscan(fid, '%f %f %f %f %f %*f %*f %*f %*f %*f %*s %*s %*s') ;
  %read the file
  a = A{1};
  e = A{2};
  c = A{3};
  x = A{4};
  y = A{5};
  %converted the euler angles into degrees
  phi1= radtodeg(a);
  phi= radtodeg(e);
  phi2= radtodeg(c);
  </code></pre>
  
  <p>here phi1 is an array of 1999999X1 similarly phi and phi2 are arrays of same size, this I am using in the later part.</p>