Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question

I need help coding in MATLAB. I want to create a function where I can input different values of n and e and I would get an output of gamma. Can you help me with that?

 

% Initial Conditions
rev = 0:0.001:4;
n1 = -1;
w1 = [n1; 0; 0];


g1 = deg2rad(8);
C1 = [cos(g1) -sin(g1) 0;
     sin(g1) cos(g1)  0;
     0      0       1];

[e1, norm_EP1] = DCMtoEP(C1);

 

% For n = -1 and e1

% Using ode45 to integrate the KDE and DDE
options = odeset('RelTol',1e-12,'AbsTol',1e-12);
result1 = ode45(@K_DDE, rev, [w1; e1; n1], options);

% Extracting information from the ode45 solver
v1 = result1.x;
w_ode1 = result1.y(1:3, :);
e_ode1 = result1.y(4:7, :);

 

% Finding C11
C11_1 = 1 - 2*e_ode1(2,:).^2 - 2*e_ode1(3,:).^2;

% Initializing arrays
gamma1 = zeros(1, length(v1));


% Finding the nutation angles
for i = 1:length(v1)

    gamma1(i) = acosd(C11_1(i));

end

 

 

function dwedt = K_DDE(~, w_en)

    % Extracting the initial condtions to a variable
    w = w_en(1:3);
    e = w_en(4:7);
    n = w_en(8);

    
    I = 400;
    J = 150;
    x = (J/I) - 1;
    y = n - 1;


    % Kinematic Differential Equations
    dedt = zeros(4,1);
    dedt(1) = pi*(e(4)*(w(1)-1-y) - e(3)*w(2) + e(2)*w(3));
    dedt(2) = pi*(e(3)*(w(1)+1-y) + e(4)*w(2) - e(1)*w(3));
    dedt(3) = pi*(-e(2)*(w(1)+1-y) + e(1)*w(2) + e(4)*w(3));
    dedt(4) = pi*(-e(1)*(w(1)-1-y) - e(2)*w(2) - e(3)*w(3));

    % Dynamical Differential Equations
    dwdt = zeros(3,1);
    dwdt(1) = 0;
    dwdt(2) = -24*pi*(-x)*(e(1)*e(2)+e(3)*e(4))*(e(2)*e(3)-e(1)*e(4)) ...
               + 2*pi*(-x)*w(1)*w(3) - 2*pi*w(3)*y;
    dwdt(3) = 12*pi*(-x)*(e(1)*e(2)+e(3)*e(4))*(1-2*e(3)^2-2*e(1)^2) ...
               - 2*pi*(-x)*w(1)*w(2) + 2*pi*w(2)*y;


    % Combining the w and C into one output matrix
    dwedt = [dwdt; dedt; 0];

end

Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education