Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9216897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:31:01+00:00 2026-06-18T02:31:01+00:00

I am having following problem, I have developed code for converting the large array

  • 0

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

phi1 phi phi2
2     3   5
1     2.2  4.3
3     4    5

…..there are other 2 million array of data.

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?

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]

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

del_g= inv(g1).*g2;

then I want to extract g11 and g13 elements of the resultant matrix.

The data is taken from a text file with the following data

 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

The first three columns are the euler angles phi1,phi and phi2 respectively
for extracting the data from the text file I am using

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);

here phi1 is an array of 1999999X1 similarly phi and phi2 are arrays of same size, this I am using in the later part.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T02:31:03+00:00Added an answer on June 18, 2026 at 2:31 am

    Start with making a function that gets g1, I called the function get_gi so it should be saved as a separate m file get_gi.m:

    function gi=get_gi(pvec)
    %pvec is a 1x3 vector of [phi1 phi phi2]
    g_11=((cosd(pvec(1)).*cosd(pvec(3)))-(sind(pvec(1)).*sind(pvec(3)).*cosd(pvec(2))));
    g_12=((sind(pvec(1)).*cosd(pvec(3)))+(cosd(pvec(1)).*sind(pvec(3)).*cosd(pvec(2))));
    g_13= (sind(pvec(3)).*sind(pvec(2)));
    g_21 =((-cosd(pvec(1)).*sind(pvec(3)))-(sind(pvec(1)).*cos(pvec(3)).*cos(pvec(2)))); 
    g_22 = ((-sin(pvec(1)).*sind(pvec(3)))+(cosd(pvec(1)).*cosd(pvec(3)).*cosd(pvec(2))));
    g_23 = (cosd(pvec(3)).*sind(pvec(2)));
    g_31 = (sind(pvec(1)).* sind(pvec(2)));
    g_32 = -cosd(pvec(1)).* sind(pvec(2));
    g_33 = cosd(pvec(2)); 
    
    gi =[g_11 g_12 g_13;g_21 g_22 g_23;g_31 g_32 g_33];
    

    then you can loop over your large array (call it LA), getting all the g you need, and while at it, so the calculation you want:

    for ii=1:n-1
    del_g= inv(get_gi(LA(ii,:)).*get_gi(LA(ii+1,:);
    ans(ii,:) =   [del_g(1,1) del_g(1,3)];
    end
    

    Is that what you wanted?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having the following problem: a) I have a UNIX build environment set
I have been having the following problem, i think it's probably due to the
I am having a strange problem which I don't understand. I have the following
I'm having the following problem. I have Visual Web Developer 2010 Express and I'm
I am having a problem with deploying a web application I have developed. It
I'm having the following problem: I have a ListView and I get the layout
I am having the following problem that I cannot solve. Let's say I have
I have followed the following documentation and I am having problems. I access the
I am having problems with passing arguments to new threads, I have the following
i'm having a problem with my database. I have the folowing: create table book

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.